This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MNG-6065 in repository https://gitbox.apache.org/repos/asf/maven.git
commit b01235c7ef173cae7957d6be54600f6bc67831be Author: Martin Kanters <mkanter...@gmail.com> AuthorDate: Sun Dec 8 10:58:43 2019 +0100 Log fail-level option. Submitted by: Martin Kanters. Renamed the flag --fail-level to --fail-on-severity --- maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java | 4 ++-- maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java | 6 +++--- .../main/java/org/apache/maven/cli/event/ExecutionEventLogger.java | 2 +- .../{MavenFailLevelLogger.java => MavenFailOnSeverityLogger.java} | 6 +++--- .../src/main/java/org/slf4j/impl/MavenLoggerFactory.java | 6 +++--- .../src/main/java/org/apache/maven/logwrapper/LogLevelRecorder.java | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index ea67fde..ec5e1b1 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -77,7 +77,7 @@ public class CLIManager public static final String FAIL_FAST = "ff"; - public static final String FAIL_LEVEL = "fl"; + public static final String FAIL_ON_SEVERITY = "fos"; public static final String FAIL_AT_END = "fae"; @@ -130,7 +130,7 @@ public class CLIManager options.addOption( Option.builder( ALTERNATE_GLOBAL_SETTINGS ).longOpt( "global-settings" ).desc( "Alternate path for the global settings file" ).hasArg().build() ); options.addOption( Option.builder( Character.toString( ALTERNATE_USER_TOOLCHAINS ) ).longOpt( "toolchains" ).desc( "Alternate path for the user toolchains file" ).hasArg().build() ); options.addOption( Option.builder( ALTERNATE_GLOBAL_TOOLCHAINS ).longOpt( "global-toolchains" ).desc( "Alternate path for the global toolchains file" ).hasArg().build() ); - options.addOption( Option.builder( FAIL_LEVEL ).longOpt( "fail-level" ).desc( "Configure which level of logging should cause the build to fail" ).hasArgs().build() ); + options.addOption( Option.builder( FAIL_ON_SEVERITY ).longOpt( "fail-on-severity" ).desc( "Configure which severity of logging should cause the build to fail" ).hasArgs().build() ); options.addOption( Option.builder( FAIL_FAST ).longOpt( "fail-fast" ).desc( "Stop at first failure in reactorized builds" ).build() ); options.addOption( Option.builder( FAIL_AT_END ).longOpt( "fail-at-end" ).desc( "Only fail the build afterwards; allow all non-impacted builds to continue" ).build() ); options.addOption( Option.builder( FAIL_NEVER ).longOpt( "fail-never" ).desc( "NEVER fail the build, regardless of project result" ).build() ); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index d8557c6..215d108 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -545,9 +545,9 @@ public class MavenCli plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() ); - if ( cliRequest.commandLine.hasOption( CLIManager.FAIL_LEVEL ) ) + if ( cliRequest.commandLine.hasOption( CLIManager.FAIL_ON_SEVERITY ) ) { - String logLevelThreshold = cliRequest.commandLine.getOptionValue( CLIManager.FAIL_LEVEL ); + String logLevelThreshold = cliRequest.commandLine.getOptionValue( CLIManager.FAIL_ON_SEVERITY ); if ( slf4jLoggerFactory instanceof MavenSlf4jWrapperFactory ) { @@ -558,7 +558,7 @@ public class MavenCli else { slf4jLogger.warn( "Expected LoggerFactory to be of type '{}', but found '{}' instead. " - + "The --fail-level flag will not take effect.", + + "The --fail-on-severity flag will not take effect.", MavenSlf4jWrapperFactory.class.getName(), slf4jLoggerFactory.getClass().getName()); } } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java index dc41021..ed90142 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java @@ -145,7 +145,7 @@ public class ExecutionEventLogger extends AbstractExecutionListener .ifPresent(recorder -> event.getSession().getResult().addException( new Exception( "Build failed due to log statements with a higher severity than allowed. " - + "Fix the logged issues or remove flag --fail-level (-fl)." ) ) + + "Fix the logged issues or remove flag --fail-on-severity (-fos)." ) ) ); } diff --git a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailLevelLogger.java b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailOnSeverityLogger.java similarity index 95% rename from maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailLevelLogger.java rename to maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailOnSeverityLogger.java index b4b4605..12c6cc2 100644 --- a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailLevelLogger.java +++ b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailOnSeverityLogger.java @@ -24,13 +24,13 @@ import org.slf4j.event.Level; /** * A proxy which enhances the MavenSimpleLogger with functionality to track whether a logging threshold is hit. - * Currently only support WARN and ERROR states, since it's been used for the --fail-level flag. + * Currently only support WARN and ERROR states, since it's been used for the --fail-on-severity flag. */ -public class MavenFailLevelLogger extends MavenSimpleLogger +public class MavenFailOnSeverityLogger extends MavenSimpleLogger { private final LogLevelRecorder logLevelRecorder; - MavenFailLevelLogger( String name, LogLevelRecorder logLevelRecorder ) + MavenFailOnSeverityLogger( String name, LogLevelRecorder logLevelRecorder ) { super( name ); this.logLevelRecorder = logLevelRecorder; diff --git a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenLoggerFactory.java b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenLoggerFactory.java index 914f2a5..7ef126d 100644 --- a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenLoggerFactory.java +++ b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenLoggerFactory.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; import java.util.Optional; /** - * LogFactory for Maven which can create a simple logger or a one which, if set, fails the build on a threshold. + * LogFactory for Maven which can create a simple logger or one which, if set, fails the build on a severity threshold. */ public class MavenLoggerFactory extends SimpleLoggerFactory implements MavenSlf4jWrapperFactory { @@ -37,7 +37,7 @@ public class MavenLoggerFactory extends SimpleLoggerFactory implements MavenSlf4 { if ( this.logLevelRecorder != null ) { - throw new IllegalStateException( "Maven logger fail level has already been set." ); + throw new IllegalStateException( "LogLevelRecorder has already been set." ); } this.logLevelRecorder = logLevelRecorder; @@ -76,7 +76,7 @@ public class MavenLoggerFactory extends SimpleLoggerFactory implements MavenSlf4 } else { - return new MavenFailLevelLogger( name, logLevelRecorder ); + return new MavenFailOnSeverityLogger( name, logLevelRecorder ); } } } diff --git a/maven-slf4j-wrapper/src/main/java/org/apache/maven/logwrapper/LogLevelRecorder.java b/maven-slf4j-wrapper/src/main/java/org/apache/maven/logwrapper/LogLevelRecorder.java index 0ac2957..3dac0a8 100644 --- a/maven-slf4j-wrapper/src/main/java/org/apache/maven/logwrapper/LogLevelRecorder.java +++ b/maven-slf4j-wrapper/src/main/java/org/apache/maven/logwrapper/LogLevelRecorder.java @@ -22,7 +22,7 @@ package org.apache.maven.logwrapper; import org.slf4j.event.Level; /** - * Responsible for keeping state of whether the threshold of the --fail-level flag has been hit. + * Responsible for keeping state of whether the threshold of the --fail-on-severity flag has been hit. */ public class LogLevelRecorder { @@ -34,7 +34,7 @@ public class LogLevelRecorder Level level = Level.valueOf( threshold ); if ( level.toInt() < Level.WARN.toInt() ) { - throw new IllegalArgumentException( "Logging level thresholds can only be set to WARN or ERROR" ); + throw new IllegalArgumentException( "Logging severity thresholds can only be set to WARN or ERROR" ); } logThreshold = level;