Class ForwardingLogManager
- java.lang.Object
-
- org.sosy_lab.common.log.ForwardingLogManager
-
- All Implemented Interfaces:
LogManager
- Direct Known Subclasses:
LogManagerWithoutDuplicates
public abstract class ForwardingLogManager extends Object implements LogManager
-
-
Constructor Summary
Constructors Constructor Description ForwardingLogManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract LogManager
delegate()
void
flush()
Flush all handlers of this logger.void
log(Level pPriority, Object... pArgs)
Logs any message occurring during program execution.void
log(Level pPriority, Supplier<String> pMsgSupplier)
Logs any message occurring during program execution.void
logDebugException(Throwable pE)
Log an exception solely for the purpose of debugging.void
logDebugException(Throwable pE, @Nullable String pAdditionalMessage)
Log an exception solely for the purpose of debugging.void
logException(Level pPriority, Throwable pE, @Nullable String pAdditionalMessage)
Log an exception by printing the full details to the user.void
logf(Level pPriority, String pFormat, Object... pArgs)
Logs any message occurring during program execution.void
logfDebugException(Throwable pE, String pFormat, Object... pArgs)
Log an exception solely for the purpose of debugging.void
logfException(Level pPriority, Throwable pE, String pFormat, Object... pArgs)
Log an exception by printing the full details to the user.void
logfUserException(Level pPriority, Throwable pE, String pFormat, Object... pArgs)
Log a message by printing its message to the user.void
logUserException(Level pPriority, Throwable pE, @Nullable String pAdditionalMessage)
Log a message by printing its message to the user.boolean
wouldBeLogged(Level pPriority)
Returns true if a message with the given log level would be logged.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.sosy_lab.common.log.LogManager
withComponentName
-
-
-
-
Method Detail
-
delegate
@ForOverride protected abstract LogManager delegate()
-
wouldBeLogged
public boolean wouldBeLogged(Level pPriority)
Description copied from interface:LogManager
Returns true if a message with the given log level would be logged.- Specified by:
wouldBeLogged
in interfaceLogManager
- Parameters:
pPriority
- the log level- Returns:
- whether this log level is enabled
-
log
public void log(Level pPriority, Object... pArgs)
Description copied from interface:LogManager
Logs any message occurring during program execution. The message is constructed lazily by concatenating the parts with " ". The caller should not use string concatenation to create the message in order to increase performance if the message is never logged. To make individual arguments lazy, useMoreStrings.lazyString(Supplier)
.- Specified by:
log
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepArgs
- the parts of the message (can be an arbitrary number of objects whoseObject.toString()
method is called)
-
log
public void log(Level pPriority, Supplier<String> pMsgSupplier)
Description copied from interface:LogManager
Logs any message occurring during program execution. The message is constructed lazily by asking the provided supplier if necessary.- Specified by:
log
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepMsgSupplier
- a supplier for a non-null log message
-
logf
@FormatMethod public void logf(Level pPriority, String pFormat, Object... pArgs)
Description copied from interface:LogManager
Logs any message occurring during program execution. The message is constructed lazily fromString.format(format, args)
. To make individual arguments lazy, useMoreStrings.lazyString(Supplier)
.- Specified by:
logf
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepFormat
- The format string.pArgs
- The arguments for the format string.
-
logUserException
public void logUserException(Level pPriority, Throwable pE, @Nullable String pAdditionalMessage)
Description copied from interface:LogManager
Log a message by printing its message to the user. The details (e.g., stack trace) are hidden from the user and logged with a lower log level.Use this method in cases where an expected exception with a useful error message is thrown, e.g. an InvalidConfigurationException.
If you want to log an IOException because of a write error, it is recommended to write the message like "Could not write FOO to file". The final message will then be "Could not write FOO to file FOO.txt (REASON)".
- Specified by:
logUserException
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepE
- the occurred exceptionpAdditionalMessage
- an optional message
-
logfUserException
@FormatMethod public void logfUserException(Level pPriority, Throwable pE, String pFormat, Object... pArgs)
Description copied from interface:LogManager
Log a message by printing its message to the user. The details (e.g., stack trace) are hidden from the user and logged with a lower log level.Use this method in cases where an expected exception with a useful error message is thrown, e.g. an InvalidConfigurationException.
The message is constructed lazily from
String.format(format, args)
. To make individual arguments lazy, useMoreStrings.lazyString(Supplier)
.If you want to log an IOException because of a write error, it is recommended to write the message like "Could not write FOO to file". The final message will then be "Could not write FOO to file FOO.txt (REASON)".
- Specified by:
logfUserException
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepE
- the occurred exceptionpFormat
- The format string.pArgs
- The arguments for the format string.
-
logDebugException
public void logDebugException(Throwable pE, @Nullable String pAdditionalMessage)
Description copied from interface:LogManager
Log an exception solely for the purpose of debugging. In default configuration, this exception is not shown to the user!Use this method when you want to log an exception that was handled by the catching site, but you don't want to forget the information completely.
- Specified by:
logDebugException
in interfaceLogManager
- Parameters:
pE
- the occurred exceptionpAdditionalMessage
- an optional message
-
logfDebugException
@FormatMethod public void logfDebugException(Throwable pE, String pFormat, Object... pArgs)
Description copied from interface:LogManager
Log an exception solely for the purpose of debugging. In default configuration, this exception is not shown to the user!Use this method when you want to log an exception that was handled by the catching site, but you don't want to forget the information completely.
The message is constructed lazily from
String.format(format, args)
. To make individual arguments lazy, useMoreStrings.lazyString(Supplier)
.- Specified by:
logfDebugException
in interfaceLogManager
- Parameters:
pE
- the occurred exceptionpFormat
- The format string.pArgs
- The arguments for the format string.
-
logDebugException
public void logDebugException(Throwable pE)
Description copied from interface:LogManager
Log an exception solely for the purpose of debugging. In default configuration, this exception is not shown to the user!Use this method when you want to log an exception that was handled by the catching site, but you don't want to forget the information completely.
- Specified by:
logDebugException
in interfaceLogManager
- Parameters:
pE
- the occurred exception
-
logException
public void logException(Level pPriority, Throwable pE, @Nullable String pAdditionalMessage)
Description copied from interface:LogManager
Log an exception by printing the full details to the user.This method should only be used in cases where logUserException and logDebugException are not acceptable.
- Specified by:
logException
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepE
- the occurred exceptionpAdditionalMessage
- an optional message
-
logfException
@FormatMethod public void logfException(Level pPriority, Throwable pE, String pFormat, Object... pArgs)
Description copied from interface:LogManager
Log an exception by printing the full details to the user.This method should only be used in cases where logUserException and logDebugException are not acceptable.
The message is constructed lazily from
String.format(format, args)
. To make individual arguments lazy, useMoreStrings.lazyString(Supplier)
.- Specified by:
logfException
in interfaceLogManager
- Parameters:
pPriority
- the log level for the messagepE
- the occurred exceptionpFormat
- The format string.pArgs
- The arguments for the format string.
-
flush
public void flush()
Description copied from interface:LogManager
Flush all handlers of this logger.- Specified by:
flush
in interfaceLogManager
-
-