diff --git a/se-commons-logging/src/main/java/de/se_rwth/commons/logging/Log.java b/se-commons-logging/src/main/java/de/se_rwth/commons/logging/Log.java index a2ddce4..b00f0a7 100755 --- a/se-commons-logging/src/main/java/de/se_rwth/commons/logging/Log.java +++ b/se-commons-logging/src/main/java/de/se_rwth/commons/logging/Log.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; /** * Provides a centralized logging component. Subclasses may provide customized @@ -202,6 +203,25 @@ protected void doTrace(String msg, String logName) { } } + /** + * Log to the specified log name with level TRACE. + * + * @param msg the trace message + * @param logName the log name to use + */ + public static final void trace(Supplier msg, String logName) { + getLog().doTrace(msg, logName); + } + + /** + * Log to the specified log with level TRACE. + */ + protected void doTrace(Supplier msg, String logName) { + if (doIsTraceEnabled(logName)) { + doTrace(msg.get(), logName); + } + } + /** * Log to the specified log name with level TRACE. * @@ -223,6 +243,26 @@ protected void doTrace(String msg, Throwable t, String logName) { } } + /** + * Log to the specified log name with level TRACE. + * + * @param msg the trace message + * @param t the exception to log + * @param logName the log name to use + */ + public static final void trace(Supplier msg, Throwable t, String logName) { + getLog().doTrace(msg, t, logName); + } + + /** + * Log to the specified log with level TRACE.
+ */ + protected void doTrace(Supplier msg, Throwable t, String logName) { + if (doIsTraceEnabled(logName)) { + doTrace(msg.get(), t, logName); + } + } + /** * Is level DEBUG enabled for the given log name? * @@ -260,6 +300,25 @@ protected void doDebug(String msg, String logName) { } } + /** + * Log to the specified log name with level DEBUG. + * + * @param msg the debug message + * @param logName the log name to use + */ + public static final void debug(Supplier msg, String logName) { + getLog().doDebug(msg, logName); + } + + /** + * Log to the specified log with level DEBUG. + */ + protected void doDebug(Supplier msg, String logName) { + if (doIsDebugEnabled(logName)) { + doDebug(msg.get(), logName); + } + } + public static final void debug(String msg, SourcePosition pos, String logName) { getLog().doDebug(msg, pos, logName); } @@ -270,6 +329,16 @@ protected void doDebug(String msg, SourcePosition pos, String logName) { } } + public static final void debug(Supplier msg, SourcePosition pos, String logName) { + getLog().doDebug(msg, pos, logName); + } + + protected void doDebug(Supplier msg, SourcePosition pos, String logName) { + if (doIsDebugEnabled(logName)) { + doDebug(msg.get(), pos, logName); + } + } + public static final void debug(String msg, SourcePosition start, SourcePosition end, String logName) { getLog().doDebug(msg, start, end, logName); } @@ -280,6 +349,16 @@ protected void doDebug(String msg, SourcePosition start, SourcePosition end, Str } } + public static final void debug(Supplier msg, SourcePosition start, SourcePosition end, String logName) { + getLog().doDebug(msg, start, end, logName); + } + + protected void doDebug(Supplier msg, SourcePosition start, SourcePosition end, String logName) { + if (doIsDebugEnabled(logName)) { + doDebug(msg.get(), start, end, logName); + } + } + /** * Log to the specified log name with level DEBUG. * @@ -301,6 +380,26 @@ protected void doDebug(String msg, Throwable t, String logName) { } } + /** + * Log to the specified log name with level DEBUG. + * + * @param msg the debug message + * @param t the exception to log + * @param logName the log name to use + */ + public static final void debug(Supplier msg, Throwable t, String logName) { + getLog().doDebug(msg, t, logName); + } + + /** + * Log to the specified log with level DEBUG. + */ + protected void doDebug(Supplier msg, Throwable t, String logName) { + if (doIsDebugEnabled(logName)) { + doDebug(msg.get(), t, logName); + } + } + /** * Is level INFO enabled for the given log name? * @@ -338,6 +437,25 @@ protected void doInfo(String msg, String logName) { } } + /** + * Log to the specified log name with level INFO. + * + * @param msg the info message + * @param logName the log name to use + */ + public static final void info(Supplier msg, String logName) { + getLog().doInfo(msg, logName); + } + + /** + * Log to the specified log with level INFO. + */ + protected void doInfo(Supplier msg, String logName) { + if (doIsInfoEnabled(logName)) { + doInfo(msg.get(), logName); + } + } + /** * Log to the specified log name with level INFO. * @@ -359,6 +477,26 @@ protected void doInfo(String msg, Throwable t, String logName) { } } + /** + * Log to the specified log name with level INFO. + * + * @param msg the info message + * @param t the exception to log + * @param logName the log name to use + */ + public static final void info(Supplier msg, Throwable t, String logName) { + getLog().doInfo(msg, t, logName); + } + + /** + * Log to the specified log with level INFO. + */ + protected void doInfo(Supplier msg, Throwable t, String logName) { + if (doIsInfoEnabled(logName)) { + doInfo(msg.get(), t, logName); + } + } + /** * Log with level WARN. *