Class SysLogger
- java.lang.Object
-
- org.silverpeas.core.util.logging.sys.SysLogger
-
- All Implemented Interfaces:
SilverLogger
public class SysLogger extends Object implements SilverLogger
This logger implementation uses the Java logging system to log actually the messages.- Author:
- miguel
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
debug(Supplier<String> messageSupplier)
Logs an debugging message with the specified parameters.Level
getLevel()
Gets the log Level of this Logger.String
getNamespace()
Gets the namespace of this logger.boolean
isLoggable(Level level)
Checks if a message of the given level would actually be logged by this logger.void
log(Level level, String message, Object... parameters)
Logs a message at the specified level, with the specified parameters if any.void
log(Level level, String message, Object[] parameters, Throwable error)
Logs a message at the specified level, with the specified parameters if any and with a Throwable object if any.void
setLevel(Level level)
Sets the log level specifying which message levels will be logged by this logger.
-
-
-
Constructor Detail
-
SysLogger
protected SysLogger(String namespace)
-
-
Method Detail
-
getNamespace
public String getNamespace()
Gets the namespace of this logger. Each logger is defined by a unique dot separated namespace.- Specified by:
getNamespace
in interfaceSilverLogger
- Returns:
- the namespace of this logger.
-
getLevel
public Level getLevel()
Gets the log Level of this Logger. If no level was explicitly set for his logger, its effective level is then inherited from its parent.- Specified by:
getLevel
in interfaceSilverLogger
- Returns:
- the level of this logger.
-
setLevel
public void setLevel(Level level)
Sets the log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded. If the new level is null, it means that this node should inherit its level from its nearest ancestor with a specific (non-null) level value.- Specified by:
setLevel
in interfaceSilverLogger
- Parameters:
level
- the new value for the log level (may be null).
-
isLoggable
public boolean isLoggable(Level level)
Checks if a message of the given level would actually be logged by this logger. This check is based on the Loggers effective level, which may be inherited from its parent.- Specified by:
isLoggable
in interfaceSilverLogger
- Parameters:
level
- a logging level.- Returns:
- true if a message of the given level would actually be logged. False otherwise.
-
log
public void log(Level level, String message, Object[] parameters, Throwable error)
Logs a message at the specified level, with the specified parameters if any and with a Throwable object if any. If the logger is currently enabled for the given message level then a corresponding logging record is created and forwarded to all the registered output handlers objects.- Specified by:
log
in interfaceSilverLogger
- Parameters:
level
- the level of the message to log.message
- the message to log.parameters
- zero, one or more parameters to the message. Shouldn't be null.error
- an error to log with the message.
-
log
public void log(Level level, String message, Object... parameters)
Logs a message at the specified level, with the specified parameters if any.- Specified by:
log
in interfaceSilverLogger
- Parameters:
level
- the level of the message to log.message
- the message to log.parameters
- zero, one or more parameters to the message.
-
debug
public void debug(Supplier<String> messageSupplier)
Logs an debugging message with the specified parameters. The message is computed by a function that will be invoked only if the actual logger level is higher or equal than the message level. Usually, debugging message are computed by executing codes that shouldn't be ran in a nominal execution context. In order to avoid this code to be executed when the logger level is lower than the debug level, it can be written within a function whose the invocation is left to the logger responsibility.- Specified by:
debug
in interfaceSilverLogger
- Parameters:
messageSupplier
- a function that will computed the message to log.
-
-