created Slf4jConfiguration.Level enum to replace int

This commit is contained in:
Hervé Boutemy 2012-12-18 04:23:52 +01:00
parent e950603218
commit 8112e6a835
4 changed files with 12 additions and 16 deletions

View File

@ -310,17 +310,17 @@ private void logging( CliRequest cliRequest )
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 ) )

View File

@ -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" );
}

View File

@ -20,8 +20,6 @@
*/
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 @@
*/
public interface Slf4jConfiguration
{
public static enum Level { DEBUG, INFO, ERROR }
/**
* Set root logging level.
*
* @param level the level as defined in Plexus <code>Logger.LEVEL_*</code> and equivalent
* <code>MavenExecutionRequest.LOGGING_LEVEL_*</code> constants.
* @see Logger
* @see MavenExecutionRequest
* @param level the level
*/
void setRootLoggerLevel( int level );
void setRootLoggerLevel( Level level );
void setLoggerFile( File output );
}

View File

@ -23,7 +23,6 @@
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 @@
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;
}