Interface Logger
-
- All Known Implementing Classes:
WriterLogger
public interface LoggerDefines the interface for handling log messages.It is not usually necessary for users to create implementations of this interface, as the
LoggerProviderinterface contains several predefined instances which provide the most commonly requiredLoggerimplementations.By default, logging is configured automatically according to the algorithm described in the static
Config.LoggerProviderproperty.An instance of a class that implements this interface is used by calling the
Source.setLogger(Logger)method on the relevantSourceobject.Four logging levels are defined in this interface. The logging level is specified only by the use of different method names, there is no class or type defining the levels. This makes the code required to wrap other logging frameworks much simpler and more efficient.
The four logging levels are:
IMPLEMENTATION NOTE: Ideally the
java.util.logging.Loggerclass could have been used as a basis for logging, even if used to define a wrapper around other logging frameworks. This would have avoided the need to define yet another logging interface, but becausejava.util.logging.Loggeris implemented very poorly, it is quite tricky to extend it as a wrapper. Other logging wrapper frameworks such as SLF4J or Jakarta Commons Logging provide good logging interfaces, but to avoid introducing dependencies it was decided to create this new interface.- See Also:
Config.LoggerProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddebug(java.lang.String message)Logs a message at the DEBUG level.voiderror(java.lang.String message)Logs a message at the ERROR level.voidinfo(java.lang.String message)Logs a message at the INFO level.booleanisDebugEnabled()Indicates whether logging is enabled at the DEBUG level.booleanisErrorEnabled()Indicates whether logging is enabled at the ERROR level.booleanisInfoEnabled()Indicates whether logging is enabled at the INFO level.booleanisWarnEnabled()Indicates whether logging is enabled at the WARN level.voidwarn(java.lang.String message)Logs a message at the WARN level.
-
-
-
Method Detail
-
error
void error(java.lang.String message)
Logs a message at the ERROR level.- Parameters:
message- the message to log.
-
warn
void warn(java.lang.String message)
Logs a message at the WARN level.- Parameters:
message- the message to log.
-
info
void info(java.lang.String message)
Logs a message at the INFO level.- Parameters:
message- the message to log.
-
debug
void debug(java.lang.String message)
Logs a message at the DEBUG level.- Parameters:
message- the message to log.
-
isErrorEnabled
boolean isErrorEnabled()
Indicates whether logging is enabled at the ERROR level.- Returns:
trueif logging is enabled at the ERROR level, otherwisefalse.
-
isWarnEnabled
boolean isWarnEnabled()
Indicates whether logging is enabled at the WARN level.- Returns:
trueif logging is enabled at the WARN level, otherwisefalse.
-
isInfoEnabled
boolean isInfoEnabled()
Indicates whether logging is enabled at the INFO level.- Returns:
trueif logging is enabled at the INFO level, otherwisefalse.
-
isDebugEnabled
boolean isDebugEnabled()
Indicates whether logging is enabled at the DEBUG level.- Returns:
trueif logging is enabled at the DEBUG level, otherwisefalse.
-
-