javolution37.javolution.util
Class StandardLog
- java.lang.Object
-
- javolution37.javolution.realtime.Context
-
- javolution37.javolution.realtime.LogContext
-
- javolution37.javolution.util.StandardLog
-
public class StandardLog extends LogContext
This class represents a specialized logging context forwarding events to a standard logger (
java.util.logging.Logger).This class leverages the capabilities of the standard logging facility and extends it to support specialized
loggingon a thread or object basis. For example:StandardLog remoteLog = new StandardLog(Logger.getLogger("remote")); StandardLog.enter(remoteLog); try { StandardLog.fine("Current thread uses a remote logger"); ... } finally { StandardLog.exit(remoteLog); // Reverts to previous logging context. }
-
-
Field Summary
-
Fields inherited from class javolution37.javolution.realtime.LogContext
NULL, STANDARD, SYSTEM, SYSTEM_ERR
-
-
Constructor Summary
Constructors Constructor and Description StandardLog()Creates a logging context forwarding events to the root logger (Logger.getLogger("")).StandardLog(java.util.logging.Logger logger)Creates a standard log context forwarding events to the specified logger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidconfig(java.lang.String msg)Logs aCONFIGmessage.static voidentering(java.lang.String sourceClass, java.lang.String sourceMethod)Log a method entry.static voidexiting(java.lang.String sourceClass, java.lang.String sourceMethod)Log a method return.static voidfine(java.lang.String msg)Logs aFINEmessage.static voidfiner(java.lang.String msg)Logs aFINERmessage.static voidfinest(java.lang.String msg)Logs aFINESTmessage.java.util.logging.LoggergetLogger()Returns the logger to which this context forwards the events to.static voidinfo(java.lang.String msg)Logs anINFOmessage.booleanisErrorLogged()Indicates if errors are logged.booleanisInfoLogged()Indicates if informative messages are logged.static booleanisLoggable(java.util.logging.Level level)Checks if a message of the given level would actually be logged by this logger.booleanisWarningLogged()Indicates if warning messages are logged.static voidlog(java.util.logging.LogRecord record)Log a specific LogRecord.voidlogError(java.lang.Throwable error, java.lang.CharSequence message)Logs the specified error.voidlogInfo(java.lang.CharSequence message)Logs the specified informative message.voidlogWarning(java.lang.CharSequence message)Logs the specified warning message.static voidsevere(java.lang.String msg)Logs aSEVEREmessage.static voidthrowing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)Logs throwing an exception.static voidwarning(java.lang.String msg)Logs aWARNINGmessage.-
Methods inherited from class javolution37.javolution.realtime.LogContext
current, error, error, getDefault, info, setDefault, warning
-
-
-
-
Constructor Detail
-
StandardLog
public StandardLog()
Creates a logging context forwarding events to the root logger (Logger.getLogger("")).
-
StandardLog
public StandardLog(java.util.logging.Logger logger)
Creates a standard log context forwarding events to the specified logger.- Parameters:
logger- the logger to which log events are forwarded to.
-
-
Method Detail
-
getLogger
public final java.util.logging.Logger getLogger()
Returns the logger to which this context forwards the events to.- Returns:
- the logger for this standard logging context.
-
isLoggable
public static boolean isLoggable(java.util.logging.Level level)
Checks if a message of the given level would actually be logged by this logger.- Parameters:
level- the message logging level- Returns:
trueif a message of specified level would actually be logged;falseotherwise.
-
log
public static void log(java.util.logging.LogRecord record)
Log a specific LogRecord. If the current logging context is not aStandardLog, anerror,warningorinfois possibly logged.- Parameters:
record- the LogRecord to be published.
-
severe
public static void severe(java.lang.String msg)
Logs aSEVEREmessage. If the current logging context is not aStandardLogawarningmessage is logged.- Parameters:
msg- the severe message.
-
warning
public static void warning(java.lang.String msg)
Logs aWARNINGmessage.- Parameters:
msg- the warning message.- See Also:
LogContext.logWarning(CharSequence)
-
info
public static void info(java.lang.String msg)
Logs anINFOmessage.- Parameters:
msg- the informative message.- See Also:
LogContext.logInfo(CharSequence)
-
config
public static void config(java.lang.String msg)
Logs aCONFIGmessage. If the current logging context is not aStandardLogno message is logged.- Parameters:
msg- the config message.
-
fine
public static void fine(java.lang.String msg)
Logs aFINEmessage. If the current logging context is not aStandardLogno message is logged.- Parameters:
msg- the fine message.
-
finer
public static void finer(java.lang.String msg)
Logs aFINERmessage. If the current logging context is not aStandardLogno message is logged.- Parameters:
msg- the finer message.
-
finest
public static void finest(java.lang.String msg)
Logs aFINESTmessage. If the current logging context is not aStandardLogno message is logged.- Parameters:
msg- the finest message.
-
throwing
public static void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)Logs throwing an exception. If the current logging context is not aStandardLoganerroris logged.- Parameters:
sourceClass- name of class that issued the logging request.sourceMethod- name of the method.thrown- the error that is being thrown.
-
entering
public static void entering(java.lang.String sourceClass, java.lang.String sourceMethod)Log a method entry. If the current logging context is not aStandardLogno entry is logged.- Parameters:
sourceClass- name of class that issued the logging request.sourceMethod- name of method that is being entered.
-
exiting
public static void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)Log a method return. If the current logging context is not aStandardLogno return is logged.- Parameters:
sourceClass- name of class that issued the logging request.sourceMethod- name of method that is being returned.
-
isInfoLogged
public boolean isInfoLogged()
Description copied from class:LogContextIndicates if informative messages are logged.- Specified by:
isInfoLoggedin classLogContext- Returns:
trueif informative messages are logged;falseotherwise.
-
isWarningLogged
public boolean isWarningLogged()
Description copied from class:LogContextIndicates if warning messages are logged.- Specified by:
isWarningLoggedin classLogContext- Returns:
trueif warnings message are logged;falseotherwise.
-
isErrorLogged
public boolean isErrorLogged()
Description copied from class:LogContextIndicates if errors are logged.- Specified by:
isErrorLoggedin classLogContext- Returns:
trueif errors are logged;falseotherwise.
-
logInfo
public void logInfo(java.lang.CharSequence message)
Description copied from class:LogContextLogs the specified informative message.- Specified by:
logInfoin classLogContext- Parameters:
message- the informative message being logged.
-
logWarning
public void logWarning(java.lang.CharSequence message)
Description copied from class:LogContextLogs the specified warning message.- Specified by:
logWarningin classLogContext- Parameters:
message- the warning message being logged.
-
logError
public void logError(java.lang.Throwable error, java.lang.CharSequence message)Description copied from class:LogContextLogs the specified error.- Specified by:
logErrorin classLogContext- Parameters:
error- the error being logged.message- the associated message ornullif none.
-
-
DMelt 3.0 © DataMelt by jWork.ORG