Adding ability to undo the log-level change, to some extent...it's not too elegant, but it should work in most cases.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@498043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-01-20 02:02:47 +00:00
parent 4ca4301f1d
commit cf308da3de
1 changed files with 19 additions and 9 deletions

View File

@ -59,6 +59,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.logging.LoggerManager;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File; import java.io.File;
@ -565,18 +566,27 @@ public class MavenEmbedder
public MavenExecutionResult execute( MavenExecutionRequest request ) public MavenExecutionResult execute( MavenExecutionRequest request )
{ {
LoggerManager loggerManager = container.getLoggerManager();
container.getLoggerManager().setThresholds( request.getLoggingLevel() ); int oldThreshold = loggerManager.getThreshold();
try try
{ {
request = defaultsPopulator.populateDefaults( request ); loggerManager.setThresholds( request.getLoggingLevel() );
}
catch ( MavenEmbedderException e ) try
{ {
return new DefaultMavenExecutionResult( Collections.singletonList( e ) ); request = defaultsPopulator.populateDefaults( request );
} }
catch ( MavenEmbedderException e )
{
return new DefaultMavenExecutionResult( Collections.singletonList( e ) );
}
return maven.execute( request ); return maven.execute( request );
}
finally
{
loggerManager.setThresholds( oldThreshold );
}
} }
} }