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.LoggerThe 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.ResourceBundlecatalogprotected java.util.LocalecatalogLocaleprotected java.lang.StringcatalogNameprotected IClockServiceclockThe clock service.protected java.util.logging.LoggerloggerThe original logger.protected static intoffValue
-
Constructor Summary
Constructors Constructor Description LoggerWrapper(java.util.logging.Logger logger, IClockService clock)Create a new logger wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(java.util.logging.Handler handler)Add a log Handler to receive logging messages.voidconfig(java.lang.String msg)Log a CONFIG message.java.util.logging.LogRecordcreateLogRecord(java.util.logging.Level level, java.lang.String msg, long time)static java.util.ResourceBundlefindResourceBundle(java.lang.String name, java.util.Locale currentLocale, java.lang.ClassLoader cl)Try to find aResourceBundleby trying Classloaders from all calling Classes.voidfine(java.lang.String msg)Log a FINE message.voidfiner(java.lang.String msg)Log a FINER message.voidfinest(java.lang.String msg)Log a FINEST message.java.util.logging.FiltergetFilter()Get the current filter for this Logger.java.util.logging.Handler[]getHandlers()Get the Handlers associated with this logger.java.util.logging.LevelgetLevel()Get the log Level that has been specified for this Logger.java.lang.StringgetName()Get the name for this logger.java.util.logging.LoggergetParent()Return the parent for this Logger.java.util.ResourceBundlegetResourceBundle()Retrieve the localization resource bundle for this logger for the current default locale.java.lang.StringgetResourceBundleName()Retrieve the localization resource bundle name for this logger.protected longgetTime()Get the time.booleangetUseParentHandlers()Discover whether or not this logger is sending its output to its parent logger.voidinfo(java.lang.String msg)Log an INFO message.booleanisLoggable(java.util.logging.Level level)Check if a message of the given level would actually be logged by this logger.voidlog(java.util.logging.Level level, java.lang.String msg)Log a message, with no arguments.voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)Log a message, with one object parameter.voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)Log a message, with an array of object arguments.voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)Log a message, with associated Throwable information.voidlog(java.util.logging.LogRecord record)Log a LogRecord.voidlogp(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.voidlogp(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.voidlogp(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.voidlogp(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.voidlogrb(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.voidlogrb(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.voidlogrb(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.voidlogrb(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.voidremoveHandler(java.util.logging.Handler handler)Remove a log Handler.voidsetFilter(java.util.logging.Filter newFilter)Set a filter to control output on this Logger.voidsetLevel(java.util.logging.Level newLevel)Set the log level specifying which message levels will be logged by this logger.voidsetParent(java.util.logging.Logger parent)Set the parent for this Logger.voidsetUseParentHandlers(boolean useParentHandlers)Specify whether or not this logger should send its output to it's parent Logger.voidsevere(java.lang.String msg)Log a SEVERE message.voidthrowing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)Log throwing an exception.voidwarning(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:
getResourceBundlein 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:
getResourceBundleNamein classjava.util.logging.Logger- Returns:
- localization bundle name (may be null)
-
setFilter
public void setFilter(java.util.logging.Filter newFilter) throws java.lang.SecurityExceptionSet a filter to control output on this Logger.- Overrides:
setFilterin 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:
getFilterin classjava.util.logging.Logger- Returns:
- a filter object (may be null)
-
log
public void log(java.util.logging.LogRecord record)
Log a LogRecord.- Overrides:
login 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:
login 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:
login 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:
login 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:
login 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:
logpin 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:
logpin 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:
logpin 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:
logpin 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:
logrbin 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:
logrbin 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:
logrbin 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:
logrbin 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:
throwingin 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.SecurityExceptionSet 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:
setLevelin 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:
getLevelin 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:
isLoggablein 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:
getNamein 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.SecurityExceptionAdd a log Handler to receive logging messages.- Overrides:
addHandlerin 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.SecurityExceptionRemove a log Handler.- Overrides:
removeHandlerin 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:
getHandlersin 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:
setUseParentHandlersin 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:
getUseParentHandlersin 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:
getParentin 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:
setParentin 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:
severein 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:
warningin 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:
infoin 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:
configin 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:
finein 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:
finerin 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:
finestin classjava.util.logging.Logger- Parameters:
msg- The string message (or a key in the message catalog)
-
findResourceBundle
public static java.util.ResourceBundle findResourceBundle(java.lang.String name, java.util.Locale currentLocale, java.lang.ClassLoader cl)Try to find aResourceBundleby trying Classloaders from all calling Classes.- Parameters:
name- Name of the ResourceBundle to findcurrentLocale- Name of the localecl- the default classloader- Returns:
- The found
ResourceBundleornull.
-
-