Package jadex.bridge.service.types.cms
Class LoggerWrapper
- java.lang.Object
-
- java.util.logging.Logger
-
- jadex.bridge.service.types.cms.LoggerWrapper
-
public class LoggerWrapper extends java.util.logging.Logger
The logger wrapper is used to encapsulate a logger and redirect messages to the logger with the correct time (according to a clock service). Overrides the log methods and always sets the log record time to the value of the clock service. Then delegates the calls to the original logger.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ResourceBundle
catalog
protected java.util.Locale
catalogLocale
protected java.lang.String
catalogName
protected IClockService
clock
The clock service.protected java.util.logging.Logger
logger
The original logger.protected static int
offValue
-
Constructor Summary
Constructors Constructor Description LoggerWrapper(java.util.logging.Logger logger, IClockService clock)
Create a new logger wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(java.util.logging.Handler handler)
Add a log Handler to receive logging messages.void
config(java.lang.String msg)
Log a CONFIG message.java.util.logging.LogRecord
createLogRecord(java.util.logging.Level level, java.lang.String msg, long time)
void
fine(java.lang.String msg)
Log a FINE message.void
finer(java.lang.String msg)
Log a FINER message.void
finest(java.lang.String msg)
Log a FINEST message.java.util.logging.Filter
getFilter()
Get the current filter for this Logger.java.util.logging.Handler[]
getHandlers()
Get the Handlers associated with this logger.java.util.logging.Level
getLevel()
Get the log Level that has been specified for this Logger.java.lang.String
getName()
Get the name for this logger.java.util.logging.Logger
getParent()
Return the parent for this Logger.java.util.ResourceBundle
getResourceBundle()
Retrieve the localization resource bundle for this logger for the current default locale.java.lang.String
getResourceBundleName()
Retrieve the localization resource bundle name for this logger.protected long
getTime()
Get the time.boolean
getUseParentHandlers()
Discover whether or not this logger is sending its output to its parent logger.void
info(java.lang.String msg)
Log an INFO message.boolean
isLoggable(java.util.logging.Level level)
Check if a message of the given level would actually be logged by this logger.void
log(java.util.logging.Level level, java.lang.String msg)
Log a message, with no arguments.void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)
Log a message, with one object parameter.void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)
Log a message, with an array of object arguments.void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)
Log a message, with associated Throwable information.void
log(java.util.logging.LogRecord record)
Log a LogRecord.void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Log a message, specifying source class and method, with no arguments.void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)
Log a message, specifying source class and method, with a single object parameter to the log message.void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)
Log a message, specifying source class and method, with an array of object arguments.void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)
Log a message, specifying source class and method, with associated Throwable information.void
logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)
Log a message, specifying source class, method, and resource bundle name with no arguments.void
logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param1)
Log a message, specifying source class, method, and resource bundle name, with a single object parameter to the log message.void
logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)
Log a message, specifying source class, method, and resource bundle name, with an array of object arguments.void
logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)
Log a message, specifying source class, method, and resource bundle name, with associated Throwable information.void
removeHandler(java.util.logging.Handler handler)
Remove a log Handler.void
setFilter(java.util.logging.Filter newFilter)
Set a filter to control output on this Logger.void
setLevel(java.util.logging.Level newLevel)
Set the log level specifying which message levels will be logged by this logger.void
setParent(java.util.logging.Logger parent)
Set the parent for this Logger.void
setUseParentHandlers(boolean useParentHandlers)
Specify whether or not this logger should send its output to it's parent Logger.void
severe(java.lang.String msg)
Log a SEVERE message.void
throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
Log throwing an exception.void
warning(java.lang.String msg)
Log a WARNING message.
-
-
-
Field Detail
-
logger
protected java.util.logging.Logger logger
The original logger.
-
clock
protected IClockService clock
The clock service.
-
offValue
protected static final int offValue
-
catalog
protected java.util.ResourceBundle catalog
-
catalogName
protected java.lang.String catalogName
-
catalogLocale
protected java.util.Locale catalogLocale
-
-
Constructor Detail
-
LoggerWrapper
public LoggerWrapper(java.util.logging.Logger logger, IClockService clock)
Create a new logger wrapper.
-
-
Method Detail
-
createLogRecord
public java.util.logging.LogRecord createLogRecord(java.util.logging.Level level, java.lang.String msg, long time)
-
getResourceBundle
public java.util.ResourceBundle getResourceBundle()
Retrieve the localization resource bundle for this logger for the current default locale. Note that if the result is null, then the Logger will use a resource bundle inherited from its parent.- Overrides:
getResourceBundle
in classjava.util.logging.Logger
- Returns:
- localization bundle (may be null)
-
getResourceBundleName
public java.lang.String getResourceBundleName()
Retrieve the localization resource bundle name for this logger. Note that if the result is null, then the Logger will use a resource bundle name inherited from its parent.- Overrides:
getResourceBundleName
in classjava.util.logging.Logger
- Returns:
- localization bundle name (may be null)
-
setFilter
public void setFilter(java.util.logging.Filter newFilter) throws java.lang.SecurityException
Set a filter to control output on this Logger.- Overrides:
setFilter
in classjava.util.logging.Logger
- Parameters:
newFilter
- a filter object (may be null)- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
getFilter
public java.util.logging.Filter getFilter()
Get the current filter for this Logger.- Overrides:
getFilter
in classjava.util.logging.Logger
- Returns:
- a filter object (may be null)
-
log
public void log(java.util.logging.LogRecord record)
Log a LogRecord.- Overrides:
log
in classjava.util.logging.Logger
- Parameters:
record
- the LogRecord to be published
-
log
public void log(java.util.logging.Level level, java.lang.String msg)
Log a message, with no arguments.- Overrides:
log
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREmsg
- The string message (or a key in the message catalog)
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)
Log a message, with one object parameter.- Overrides:
log
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREmsg
- The string message (or a key in the message catalog)param1
- parameter to the message
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)
Log a message, with an array of object arguments.- Overrides:
log
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREmsg
- The string message (or a key in the message catalog)params
- array of parameters to the message
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)
Log a message, with associated Throwable information.- Overrides:
log
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREmsg
- The string message (or a key in the message catalog)thrown
- Throwable associated with log message.
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Log a message, specifying source class and method, with no arguments.- Overrides:
logp
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestmsg
- The string message (or a key in the message catalog)
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)
Log a message, specifying source class and method, with a single object parameter to the log message.- Overrides:
logp
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestmsg
- The string message (or a key in the message catalog)param1
- Parameter to the log message.
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)
Log a message, specifying source class and method, with an array of object arguments.- Overrides:
logp
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestmsg
- The string message (or a key in the message catalog)params
- Array of parameters to the message
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)
Log a message, specifying source class and method, with associated Throwable information.- Overrides:
logp
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestmsg
- The string message (or a key in the message catalog)thrown
- Throwable associated with log message.
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)
Log a message, specifying source class, method, and resource bundle name with no arguments.- Overrides:
logrb
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestbundleName
- name of resource bundle to localize msg, can be nullmsg
- The string message (or a key in the message catalog)
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param1)
Log a message, specifying source class, method, and resource bundle name, with a single object parameter to the log message.- Overrides:
logrb
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestbundleName
- name of resource bundle to localize msg, can be nullmsg
- The string message (or a key in the message catalog)param1
- Parameter to the log message.
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)
Log a message, specifying source class, method, and resource bundle name, with an array of object arguments.- Overrides:
logrb
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestbundleName
- name of resource bundle to localize msg, can be null.msg
- The string message (or a key in the message catalog)params
- Array of parameters to the message
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)
Log a message, specifying source class, method, and resource bundle name, with associated Throwable information.- Overrides:
logrb
in classjava.util.logging.Logger
- Parameters:
level
- One of the message level identifiers, e.g. SEVEREsourceClass
- name of class that issued the logging requestsourceMethod
- name of method that issued the logging requestbundleName
- name of resource bundle to localize msg, can be nullmsg
- The string message (or a key in the message catalog)thrown
- Throwable associated with log message.
-
throwing
public void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
Log throwing an exception.- Overrides:
throwing
in classjava.util.logging.Logger
- Parameters:
sourceClass
- name of class that issued the logging requestsourceMethod
- name of the method.thrown
- The Throwable that is being thrown.
-
setLevel
public void setLevel(java.util.logging.Level newLevel) throws java.lang.SecurityException
Set the log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded. The level value Level.OFF can be used to turn off logging.- Overrides:
setLevel
in classjava.util.logging.Logger
- Parameters:
newLevel
- the new value for the log level (may be null)- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
getLevel
public java.util.logging.Level getLevel()
Get the log Level that has been specified for this Logger. The result may be null, which means that this logger's effective level will be inherited from its parent.- Overrides:
getLevel
in classjava.util.logging.Logger
- Returns:
- this Logger's level
-
isLoggable
public boolean isLoggable(java.util.logging.Level level)
Check 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.- Overrides:
isLoggable
in classjava.util.logging.Logger
- Parameters:
level
- a message logging level- Returns:
- true if the given message level is currently being logged.
-
getName
public java.lang.String getName()
Get the name for this logger.- Overrides:
getName
in classjava.util.logging.Logger
- Returns:
- logger name. Will be null for anonymous Loggers.
-
addHandler
public void addHandler(java.util.logging.Handler handler) throws java.lang.SecurityException
Add a log Handler to receive logging messages.- Overrides:
addHandler
in classjava.util.logging.Logger
- Parameters:
handler
- a logging Handler- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
removeHandler
public void removeHandler(java.util.logging.Handler handler) throws java.lang.SecurityException
Remove a log Handler.- Overrides:
removeHandler
in classjava.util.logging.Logger
- Parameters:
handler
- a logging Handler- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
getHandlers
public java.util.logging.Handler[] getHandlers()
Get the Handlers associated with this logger.- Overrides:
getHandlers
in classjava.util.logging.Logger
- Returns:
- an array of all registered Handlers
-
setUseParentHandlers
public void setUseParentHandlers(boolean useParentHandlers)
Specify whether or not this logger should send its output to it's parent Logger. This means that any LogRecords will also be written to the parent's Handlers, and potentially to its parent, recursively up the namespace.- Overrides:
setUseParentHandlers
in classjava.util.logging.Logger
- Parameters:
useParentHandlers
- true if output is to be sent to the logger's parent.- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
getUseParentHandlers
public boolean getUseParentHandlers()
Discover whether or not this logger is sending its output to its parent logger.- Overrides:
getUseParentHandlers
in classjava.util.logging.Logger
- Returns:
- true if output is to be sent to the logger's parent
-
getParent
public java.util.logging.Logger getParent()
Return the parent for this Logger.- Overrides:
getParent
in classjava.util.logging.Logger
- Returns:
- nearest existing parent Logger
-
setParent
public void setParent(java.util.logging.Logger parent)
Set the parent for this Logger. This method is used by the LogManager to update a Logger when the namespace changes.- Overrides:
setParent
in classjava.util.logging.Logger
- Parameters:
parent
- the new parent logger- Throws:
java.lang.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
getTime
protected long getTime()
Get the time.
-
severe
public void severe(java.lang.String msg)
Log a SEVERE message.- Overrides:
severe
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
warning
public void warning(java.lang.String msg)
Log a WARNING message.- Overrides:
warning
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
info
public void info(java.lang.String msg)
Log an INFO message.- Overrides:
info
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
config
public void config(java.lang.String msg)
Log a CONFIG message.- Overrides:
config
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
fine
public void fine(java.lang.String msg)
Log a FINE message.- Overrides:
fine
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
finer
public void finer(java.lang.String msg)
Log a FINER message.- Overrides:
finer
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
finest
public void finest(java.lang.String msg)
Log a FINEST message.- Overrides:
finest
in classjava.util.logging.Logger
- Parameters:
msg
- The string message (or a key in the message catalog)
-
-