cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET );
cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
if ( cliRequest.debug )
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG );
}
else if ( cliRequest.quiet )
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR );
}
else
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.INFO );
}
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
{
File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) );
logFile = resolveFile( logFile, cliRequest.workingDirectory );
// redirect stdout and stderr to file
try
{
PrintStream ps = new PrintStream( new FileOutputStream( logFile ) );
System.setOut( ps );
System.setErr( ps );
}
catch ( FileNotFoundException e )
{
//
// Ignore
//
}
}
slf4jConfiguration.activate();
plexusLoggerManager = new Slf4jLoggerManager();
slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
}