mirror of https://github.com/apache/maven.git
created Slf4jConfiguration.Level enum to replace int
This commit is contained in:
parent
e950603218
commit
8112e6a835
|
@ -310,17 +310,17 @@ public class MavenCli
|
||||||
if ( cliRequest.debug )
|
if ( cliRequest.debug )
|
||||||
{
|
{
|
||||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
||||||
slf4jConfiguration.setRootLoggerLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG );
|
||||||
}
|
}
|
||||||
else if ( cliRequest.quiet )
|
else if ( cliRequest.quiet )
|
||||||
{
|
{
|
||||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
||||||
slf4jConfiguration.setRootLoggerLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
|
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 ) )
|
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class AbstractSlf4jConfiguration
|
||||||
{
|
{
|
||||||
private final Logger logger = LoggerFactory.getLogger( AbstractSlf4jConfiguration.class );
|
private final Logger logger = LoggerFactory.getLogger( AbstractSlf4jConfiguration.class );
|
||||||
|
|
||||||
public void setRootLoggerLevel( int level )
|
public void setRootLoggerLevel( Level level )
|
||||||
{
|
{
|
||||||
logger.warn( "setRootLoggerLevel: operation not supported" );
|
logger.warn( "setRootLoggerLevel: operation not supported" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.apache.maven.cli.logging;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
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
|
* 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 interface Slf4jConfiguration
|
||||||
{
|
{
|
||||||
|
public static enum Level { DEBUG, INFO, ERROR }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set root logging level.
|
* Set root logging level.
|
||||||
*
|
*
|
||||||
* @param level the level as defined in Plexus <code>Logger.LEVEL_*</code> and equivalent
|
* @param level the level
|
||||||
* <code>MavenExecutionRequest.LOGGING_LEVEL_*</code> constants.
|
|
||||||
* @see Logger
|
|
||||||
* @see MavenExecutionRequest
|
|
||||||
*/
|
*/
|
||||||
void setRootLoggerLevel( int level );
|
void setRootLoggerLevel( Level level );
|
||||||
|
|
||||||
void setLoggerFile( File output );
|
void setLoggerFile( File output );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.io.File;
|
||||||
|
|
||||||
import org.apache.maven.cli.logging.AbstractSlf4jConfiguration;
|
import org.apache.maven.cli.logging.AbstractSlf4jConfiguration;
|
||||||
import org.apache.maven.cli.logging.Slf4jConfiguration;
|
import org.apache.maven.cli.logging.Slf4jConfiguration;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,20 +34,20 @@ import org.codehaus.plexus.component.annotations.Component;
|
||||||
public class Slf4jSimpleConfiguration
|
public class Slf4jSimpleConfiguration
|
||||||
extends AbstractSlf4jConfiguration
|
extends AbstractSlf4jConfiguration
|
||||||
{
|
{
|
||||||
public void setRootLoggerLevel( int level )
|
public void setRootLoggerLevel( Level level )
|
||||||
{
|
{
|
||||||
String value = "info";
|
String value = "info";
|
||||||
switch ( level )
|
switch ( level )
|
||||||
{
|
{
|
||||||
case MavenExecutionRequest.LOGGING_LEVEL_DEBUG:
|
case DEBUG:
|
||||||
value = "debug";
|
value = "debug";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MavenExecutionRequest.LOGGING_LEVEL_INFO:
|
case INFO:
|
||||||
value = "info";
|
value = "info";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MavenExecutionRequest.LOGGING_LEVEL_ERROR:
|
case ERROR:
|
||||||
value = "error";
|
value = "error";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue