-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFMP-232] Remove the Log API in favor of jboss-logging.
https://issues.redhat.com/browse/WFMP-232 Signed-off-by: James R. Perkins <[email protected]>
- Loading branch information
Showing
8 changed files
with
127 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
import org.jboss.dmr.ModelNode; | ||
import org.jboss.dmr.ModelType; | ||
import org.jboss.dmr.Property; | ||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* Generates a new {@code logging.properties} file based on the logging subsystem model. | ||
|
@@ -54,9 +55,9 @@ | |
* | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
// @TODO, we can't use AbstractLogEnabled, it is not in the maven plugin classloader. | ||
public class BootLoggingConfiguration { // extends AbstractLogEnabled { | ||
public class BootLoggingConfiguration { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(BootLoggingConfiguration.class); | ||
private static final Pattern SIZE_PATTERN = Pattern.compile("(\\d+)([kKmMgGbBtT])?"); | ||
private static final String NEW_LINE = System.lineSeparator(); | ||
|
||
|
@@ -164,11 +165,8 @@ public void generate(final Path configDir, final ModelControllerClient client) t | |
if (properties.containsKey(key)) { | ||
requiredProperties.put(key, properties.get(key)); | ||
} else { | ||
// @TODO, we can't use AbstractLogEnabled, it is not in the maven plugin classloader. | ||
// getLogger().warn(String.format("The value for the expression \"%s\" could not be resolved " + | ||
// "and may not be set at boot if no default value is available.", entry.getValue())); | ||
System.err.println(String.format("The value for the expression \"%s\" could not be resolved " | ||
+ "and may not be set at boot if no default value is available.", entry.getValue())); | ||
LOGGER.warnf("The value for the expression \"%s\" could not be resolved " | ||
+ "and may not be set at boot if no default value is available.", entry.getValue()); | ||
} | ||
iter.remove(); | ||
} | ||
|
@@ -829,12 +827,9 @@ private void resolveRelativeTo(final ModelNode pathModel, final String relativeT | |
for (Expression expression : expressions) { | ||
for (String key : expression.getKeys()) { | ||
if (!properties.containsKey(key)) { | ||
// @TODO, we can't use AbstractLogEnabled, it is not in the maven plugin classloader. | ||
// getLogger().warn(String.format("The path %s is an undefined property. If not set at boot time | ||
// unexpected results may occur.", pathEntry.asString())); | ||
System.err.println(String.format( | ||
LOGGER.warnf( | ||
"The path %s is an undefined property. If not set at boot time unexpected results may occur.", | ||
pathEntry.asString())); | ||
pathEntry.asString()); | ||
} else { | ||
// We use the property name and value directly rather than referencing the path | ||
usedProperties.put(key, properties.get(key)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
core/src/main/java/org/wildfly/plugins/core/bootablejar/Log.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
plugin/src/main/java/org/wildfly/plugin/common/MavenJBossLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.plugin.common; | ||
|
||
import java.text.MessageFormat; | ||
|
||
import org.apache.maven.plugin.logging.Log; | ||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* A logger which delegates to a {@link Log}. | ||
* <p> | ||
* For {@link #isEnabled(Level)} {@link org.jboss.logging.Logger.Level#TRACE} is ignored and | ||
* {@link org.jboss.logging.Logger.Level#FATAL} | ||
* is treated as an {@link Log#error(CharSequence, Throwable) error}. | ||
* </p> | ||
* <p> | ||
* For the log methods, {@link org.jboss.logging.Logger.Level#TRACE} is treated as a {@link Log#debug(CharSequence, Throwable) | ||
* debug} | ||
* and {@link org.jboss.logging.Logger.Level#FATAL} is treated as {@link Log#error(CharSequence, Throwable) error}. | ||
* </p> | ||
* | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class MavenJBossLogger extends Logger { | ||
private final Log mavenLogger; | ||
|
||
public MavenJBossLogger(final Log mavenLogger) { | ||
super(mavenLogger.toString()); | ||
this.mavenLogger = mavenLogger; | ||
} | ||
|
||
@Override | ||
protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, | ||
final Throwable thrown) { | ||
final String msg = parameters == null ? String.valueOf(message) | ||
: MessageFormat.format(String.valueOf(message), parameters); | ||
doMavenLog(level, msg, thrown); | ||
} | ||
|
||
@Override | ||
protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, | ||
final Throwable thrown) { | ||
final String msg = String.format(format, parameters); | ||
doMavenLog(level, msg, thrown); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(final Level level) { | ||
switch (level) { | ||
case DEBUG: | ||
return mavenLogger.isDebugEnabled(); | ||
case INFO: | ||
return mavenLogger.isInfoEnabled(); | ||
case WARN: | ||
return mavenLogger.isWarnEnabled(); | ||
case FATAL: | ||
case ERROR: | ||
return mavenLogger.isErrorEnabled(); | ||
} | ||
return false; | ||
} | ||
|
||
private void doMavenLog(final Level level, final String msg, final Throwable thrown) { | ||
switch (level) { | ||
case TRACE: | ||
case DEBUG: | ||
if (thrown == null) { | ||
mavenLogger.debug(msg); | ||
} else { | ||
mavenLogger.debug(msg, thrown); | ||
} | ||
break; | ||
case WARN: | ||
if (thrown == null) { | ||
mavenLogger.warn(msg); | ||
} else { | ||
mavenLogger.warn(msg, thrown); | ||
} | ||
break; | ||
case FATAL: | ||
case ERROR: | ||
if (thrown == null) { | ||
mavenLogger.error(msg); | ||
} else { | ||
mavenLogger.error(msg, thrown); | ||
} | ||
break; | ||
default: | ||
if (thrown == null) { | ||
mavenLogger.info(msg); | ||
} else { | ||
mavenLogger.info(msg, thrown); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters