diff --git a/src/main/java/org/jboss/logmanager/Logger.java b/src/main/java/org/jboss/logmanager/Logger.java index 3290bb7a..6863fe55 100644 --- a/src/main/java/org/jboss/logmanager/Logger.java +++ b/src/main/java/org/jboss/logmanager/Logger.java @@ -25,6 +25,7 @@ import java.util.Enumeration; import java.util.Locale; import java.util.ResourceBundle; +import java.util.function.Supplier; import java.util.logging.Filter; import java.util.logging.Handler; import java.util.logging.Level; @@ -97,7 +98,6 @@ public static Logger getLogger(final String name, final String bundleName) { super.setLevel(loggerNode.getLevel()); this.loggerNode = loggerNode; } - // Serialization protected final Object writeReplace() throws ObjectStreamException { @@ -528,6 +528,20 @@ public void severe(final String msg) { logRaw(rec); } + @Override + public void severe(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(SEVERE_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.SEVERE, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void warning(final String msg) { Filter filter = null; @@ -542,6 +556,20 @@ public void warning(final String msg) { logRaw(rec); } + @Override + public void warning(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(WARNING_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.WARNING, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void info(final String msg) { Filter filter = null; @@ -556,6 +584,20 @@ public void info(final String msg) { logRaw(rec); } + @Override + public void info(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(INFO_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.INFO, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void config(final String msg) { Filter filter = null; @@ -570,6 +612,20 @@ public void config(final String msg) { logRaw(rec); } + @Override + public void config(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(CONFIG_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.CONFIG, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void fine(final String msg) { Filter filter = null; @@ -584,6 +640,20 @@ public void fine(final String msg) { logRaw(rec); } + @Override + public void fine(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(FINE_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.FINE, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void finer(final String msg) { Filter filter = null; @@ -598,6 +668,20 @@ public void finer(final String msg) { logRaw(rec); } + @Override + public void finer(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(FINER_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.FINER, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void finest(final String msg) { Filter filter = null; @@ -612,6 +696,20 @@ public void finest(final String msg) { logRaw(rec); } + @Override + public void finest(final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(FINEST_INT)) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(Level.FINEST, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void log(final Level level, final String msg) { Filter filter = null; @@ -626,6 +724,20 @@ public void log(final Level level, final String msg) { logRaw(rec); } + @Override + public void log(final Level level, final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(level, msgSupplier.get(), LOGGER_CLASS_NAME); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void log(final Level level, final String msg, final Object param1) { Filter filter = null; @@ -672,6 +784,21 @@ public void log(final Level level, final String msg, final Throwable thrown) { logRaw(rec); } + @Override + public void log(final Level level, final Throwable thrown, final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(level, msgSupplier.get(), LOGGER_CLASS_NAME); + rec.setThrown(thrown); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg) { Filter filter = null; @@ -688,6 +815,23 @@ public void logp(final Level level, final String sourceClass, final String sourc logRaw(rec); } + @Override + public void logp(final Level level, final String sourceClass, final String sourceMethod, + final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(level, msgSupplier.get(), LOGGER_CLASS_NAME); + rec.setSourceClassName(sourceClass); + rec.setSourceMethodName(sourceMethod); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg, final Object param1) { @@ -743,7 +887,26 @@ public void logp(final Level level, final String sourceClass, final String sourc logRaw(rec); } + @Override + public void logp(final Level level, final String sourceClass, final String sourceMethod, final Throwable thrown, + final Supplier msgSupplier) { + Filter filter = null; + if (!(LogManager.PER_THREAD_LOG_FILTER && (filter = LogManager.getThreadLocalLogFilter()) != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + final ExtLogRecord rec = new ExtLogRecord(level, msgSupplier.get(), LOGGER_CLASS_NAME); + rec.setSourceClassName(sourceClass); + rec.setSourceMethodName(sourceMethod); + rec.setThrown(thrown); + if (LogManager.PER_THREAD_LOG_FILTER && filter != null && !filter.isLoggable(rec)) { + return; + } + logRaw(rec); + } + /** {@inheritDoc} */ + @Deprecated(since = "3.0", forRemoval = true) public void logrb(final Level level, final String sourceClass, final String sourceMethod, final String bundleName, final String msg) { if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) @@ -755,6 +918,7 @@ public void logrb(final Level level, final String sourceClass, final String sour } /** {@inheritDoc} */ + @Deprecated(since = "3.0", forRemoval = true) public void logrb(final Level level, final String sourceClass, final String sourceMethod, final String bundleName, final String msg, final Object param1) { if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) @@ -766,6 +930,7 @@ public void logrb(final Level level, final String sourceClass, final String sour } /** {@inheritDoc} */ + @Deprecated(since = "3.0", forRemoval = true) public void logrb(final Level level, final String sourceClass, final String sourceMethod, final String bundleName, final String msg, final Object[] params) { if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) @@ -777,6 +942,7 @@ public void logrb(final Level level, final String sourceClass, final String sour } /** {@inheritDoc} */ + @Deprecated(since = "3.0", forRemoval = true) public void logrb(final Level level, final String sourceClass, final String sourceMethod, final String bundleName, final String msg, final Throwable thrown) { if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) @@ -787,6 +953,47 @@ public void logrb(final Level level, final String sourceClass, final String sour super.logrb(level, sourceClass, sourceMethod, bundleName, msg, thrown); } + @Override + public void logrb(final Level level, final String sourceClass, final String sourceMethod, final ResourceBundle bundle, + final String msg, final Object... params) { + if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + // No local check is needed here as this will delegate to log(LogRecord) + super.logrb(level, sourceClass, sourceMethod, bundle, msg, params); + } + + @Override + public void logrb(final Level level, final ResourceBundle bundle, final String msg, final Object... params) { + if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + // No local check is needed here as this will delegate to log(LogRecord) + super.logrb(level, bundle, msg, params); + } + + @Override + public void logrb(final Level level, final String sourceClass, final String sourceMethod, final ResourceBundle bundle, + final String msg, final Throwable thrown) { + if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + // No local check is needed here as this will delegate to log(LogRecord) + super.logrb(level, sourceClass, sourceMethod, bundle, msg, thrown); + } + + @Override + public void logrb(final Level level, final ResourceBundle bundle, final String msg, final Throwable thrown) { + if (!(LogManager.PER_THREAD_LOG_FILTER && LogManager.getThreadLocalLogFilter() != null) + && !loggerNode.isLoggableLevel(level.intValue())) { + return; + } + // No local check is needed here as this will delegate to log(LogRecord) + super.logrb(level, bundle, msg, thrown); + } // alternate SPI hooks /**