From cf308da3debabd1181dc0e06f85b5ec4c3dd9268 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Sat, 20 Jan 2007 02:02:47 +0000 Subject: [PATCH] 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 --- .../apache/maven/embedder/MavenEmbedder.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index e5b7a482c2..91d6e7261f 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -59,6 +59,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; +import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; @@ -565,18 +566,27 @@ public class MavenEmbedder public MavenExecutionResult execute( MavenExecutionRequest request ) { - - container.getLoggerManager().setThresholds( request.getLoggingLevel() ); + LoggerManager loggerManager = container.getLoggerManager(); + int oldThreshold = loggerManager.getThreshold(); try { - request = defaultsPopulator.populateDefaults( request ); - } - catch ( MavenEmbedderException e ) - { - return new DefaultMavenExecutionResult( Collections.singletonList( e ) ); - } + loggerManager.setThresholds( request.getLoggingLevel() ); + + try + { + 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 ); + } } }