Class LoggingHandlerEnvironmentFacet
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
-
- org.codehaus.mojo.jaxb2.shared.environment.logging.LoggingHandlerEnvironmentFacet
-
- All Implemented Interfaces:
EnvironmentFacet
public class LoggingHandlerEnvironmentFacet extends AbstractLogAwareFacet
EnvironmentFacet for replacing Handlers from Java Util Logging with a Maven Log. This is required as an environment facet for capturing log statements from tools that use the Java Util Logging system internally - such as the JDK SchemaGen tool.- Since:
- 2.1
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
DEFAULT_LOGGER_NAMES
Standard logger names/categories for the java.util.Logger.private java.lang.String
encoding
private java.lang.String[]
loggerNamePrefixes
private java.lang.String
logPrefix
private MavenLogHandler
mavenLogHandler
private java.util.List<java.util.logging.Handler>
originalHandlers
private java.util.logging.Level
originalRootLoggerLevel
private boolean
restored
private java.util.logging.Logger
rootLogger
-
Fields inherited from class org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
log
-
-
Constructor Summary
Constructors Constructor Description LoggingHandlerEnvironmentFacet(java.lang.String logPrefix, org.apache.maven.plugin.logging.Log mavenLog, java.lang.String encoding, java.lang.String[] loggerNamePrefixes)
Creates a new JavaLoggingEnvironment, using the supplied variables to set up a MavenLogHandler.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LoggingHandlerEnvironmentFacet
create(org.apache.maven.plugin.logging.Log mavenLog, java.lang.Class<? extends AbstractJaxbMojo> caller, java.lang.String encoding)
Factory method creating a new LoggingHandlerEnvironmentFacet wrapping the supplied properties.void
restore()
Restores the original root Logger state, including Level and Handlers.void
setup()
Sets up this Environment, inferring temporary changes to environment variables or conditions.
-
-
-
Field Detail
-
DEFAULT_LOGGER_NAMES
public static final java.lang.String[] DEFAULT_LOGGER_NAMES
Standard logger names/categories for the java.util.Logger.
-
restored
private boolean restored
-
rootLogger
private java.util.logging.Logger rootLogger
-
originalRootLoggerLevel
private java.util.logging.Level originalRootLoggerLevel
-
originalHandlers
private java.util.List<java.util.logging.Handler> originalHandlers
-
mavenLogHandler
private MavenLogHandler mavenLogHandler
-
logPrefix
private java.lang.String logPrefix
-
encoding
private java.lang.String encoding
-
loggerNamePrefixes
private java.lang.String[] loggerNamePrefixes
-
-
Constructor Detail
-
LoggingHandlerEnvironmentFacet
public LoggingHandlerEnvironmentFacet(java.lang.String logPrefix, org.apache.maven.plugin.logging.Log mavenLog, java.lang.String encoding, java.lang.String[] loggerNamePrefixes)
Creates a new JavaLoggingEnvironment, using the supplied variables to set up a MavenLogHandler. The MavenLogHandler is then assigned to the root logger.- Parameters:
logPrefix
- The prefix to use for the logger, indicating which tool is used by the log. Example: "XJC" or "SchemaGen".mavenLog
- The active Maven Log.encoding
- The configured encoding.loggerNamePrefixes
- The prefixes of the Logger names to be permitted logging.
-
-
Method Detail
-
setup
public void setup()
Sets up this Environment, inferring temporary changes to environment variables or conditions. The changes must be reversible, and should be restored to their original values in therestore()
method.Redirects JUL logging statements to the Maven Log.
-
restore
public void restore()
Restores the original root Logger state, including Level and Handlers.
-
create
public static LoggingHandlerEnvironmentFacet create(org.apache.maven.plugin.logging.Log mavenLog, java.lang.Class<? extends AbstractJaxbMojo> caller, java.lang.String encoding)
Factory method creating a new LoggingHandlerEnvironmentFacet wrapping the supplied properties.- Parameters:
mavenLog
- The active Maven Log.caller
- The AbstractJaxbMojo subclass which invoked this LoggingHandlerEnvironmentFacet factory method.encoding
- The encoding used by the Maven Mojo subclass.- Returns:
- A fully set up LoggingHandlerEnvironmentFacet
-
-