From 8112e6a83544fe8acdd7efd973200157c1e7ca04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 18 Dec 2012 04:23:52 +0100 Subject: [PATCH] created Slf4jConfiguration.Level enum to replace int --- .../src/main/java/org/apache/maven/cli/MavenCli.java | 6 +++--- .../maven/cli/logging/AbstractSlf4jConfiguration.java | 2 +- .../apache/maven/cli/logging/Slf4jConfiguration.java | 11 ++++------- .../cli/logging/impl/Slf4jSimpleConfiguration.java | 9 ++++----- 4 files changed, 12 insertions(+), 16 deletions(-) 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 eb440e482e..23d2ba1dcd 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 @@ -310,17 +310,17 @@ public class MavenCli if ( cliRequest.debug ) { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG ); - slf4jConfiguration.setRootLoggerLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG ); } else if ( cliRequest.quiet ) { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR ); - slf4jConfiguration.setRootLoggerLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR ); } else { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO ); - slf4jConfiguration.setRootLoggerLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.INFO ); } if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/AbstractSlf4jConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/AbstractSlf4jConfiguration.java index 2b2ef6d288..4f89a94c5e 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/AbstractSlf4jConfiguration.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/AbstractSlf4jConfiguration.java @@ -34,7 +34,7 @@ public class AbstractSlf4jConfiguration { private final Logger logger = LoggerFactory.getLogger( AbstractSlf4jConfiguration.class ); - public void setRootLoggerLevel( int level ) + public void setRootLoggerLevel( Level level ) { logger.warn( "setRootLoggerLevel: operation not supported" ); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java index e153c96959..1ab596f44d 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java @@ -20,8 +20,6 @@ package org.apache.maven.cli.logging; */ import java.io.File; -import org.apache.maven.execution.MavenExecutionRequest; -import org.codehaus.plexus.logging.Logger; /** * Interface for configuration operations on loggers, which are not available in slf4j, then require per-slf4f-binding @@ -31,15 +29,14 @@ import org.codehaus.plexus.logging.Logger; */ public interface Slf4jConfiguration { + public static enum Level { DEBUG, INFO, ERROR } + /** * Set root logging level. * - * @param level the level as defined in Plexus Logger.LEVEL_* and equivalent - * MavenExecutionRequest.LOGGING_LEVEL_* constants. - * @see Logger - * @see MavenExecutionRequest + * @param level the level */ - void setRootLoggerLevel( int level ); + void setRootLoggerLevel( Level level ); void setLoggerFile( File output ); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java index c5d60d8df3..56304c1556 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java @@ -23,7 +23,6 @@ import java.io.File; import org.apache.maven.cli.logging.AbstractSlf4jConfiguration; import org.apache.maven.cli.logging.Slf4jConfiguration; -import org.apache.maven.execution.MavenExecutionRequest; import org.codehaus.plexus.component.annotations.Component; /** @@ -35,20 +34,20 @@ import org.codehaus.plexus.component.annotations.Component; public class Slf4jSimpleConfiguration extends AbstractSlf4jConfiguration { - public void setRootLoggerLevel( int level ) + public void setRootLoggerLevel( Level level ) { String value = "info"; switch ( level ) { - case MavenExecutionRequest.LOGGING_LEVEL_DEBUG: + case DEBUG: value = "debug"; break; - case MavenExecutionRequest.LOGGING_LEVEL_INFO: + case INFO: value = "info"; break; - case MavenExecutionRequest.LOGGING_LEVEL_ERROR: + case ERROR: value = "error"; break; }