Class AbstractLogger
- All Implemented Interfaces:
Logger
- Direct Known Subclasses:
LoggerJDK13
- Version:
- %I%
- Author:
- Rochelle Raccah
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractLogger(String loggerName, String bundleName, ClassLoader loader) Creates a new AbstractLogger. -
Method Summary
Modifier and TypeMethodDescriptionvoidLog a CONFIG message.voidLog a method entry.voidLog a method entry, with one parameter.voidLog a method entry, with an array of parameters.voidLog a method return.voidLog a method return, with result object.voidLog a message.voidLog a FINE message.voidLog a FINE message.voidLog a FINE message.voidLog a FINE message.voidLog a FINER message.voidLog a FINER message.voidLog a FINER message.voidLog a FINER message.voidLog a FINER message.voidLog a FINEST message.voidLog a FINEST message.voidLog a FINEST message.voidLog a FINEST message.voidLog a FINEST message.protected ResourceBundleGet the message bundle for the named instance of the logger.intgetLevel()protected StringgetMessage(String message) This method returns a string from the bundle file if possible, treating the message argument as the key.protected static ResourceBundleGet the message bundle for the AbstractLogger itself.protected StringgetMessageWithPrefix(int level, String message) This method returns a string with a formatted prefix which depends on the level.getName()Get the name for this logger.voidLog an INFO message.booleanReturn whether logging is enabled at the FINE level.booleanisLoggable(int levelValue) Check if a message of the given level would actually be logged by this logger.voidLog a message.voidLog a message.voidLog a message.voidLog a message.voidLog a message.abstract voidLog a message.protected abstract voidlogInternal(int level, String message) This method does the actual logging.voidLog a SEVERE message.voidLog throwing an exception.toString()Prepare a printable version of this instance.static StringtoString(int level) Return the string name of a level given its int value.voidLog a WARNING message.
-
Constructor Details
-
AbstractLogger
Creates a new AbstractLogger. The supplied class loader or the loader which loaded this class must be able to load the bundle.- Parameters:
loggerName- the full domain name of this loggerbundleName- the bundle name for message translationloader- the loader used for looking up the bundle file and possibly the logging.properties or alternative file
-
-
Method Details
-
getMessages
Get the message bundle for the AbstractLogger itself. -
toString
Return the string name of a level given its int value.- Returns:
- a string representing the level
-
getBundle
Get the message bundle for the named instance of the logger. -
getLevel
public int getLevel() -
isLoggable
public boolean isLoggable()Return whether logging is enabled at the FINE level. This method is not exact because to make it accurately reflect the logging level we would have to include the JDK 1.4 java.util.logging.Level class. This method does not delegate to isLoggable(FINE) for performance reasons.- Specified by:
isLoggablein interfaceLogger- Returns:
- whether logging is enabled at the fine level.
-
isLoggable
public boolean isLoggable(int levelValue) Check if a message of the given level would actually be logged by this logger. This check is based on the Logger's effective level, which may be inherited from its parent.- Specified by:
isLoggablein interfaceLogger- Parameters:
levelValue- the level to check- Returns:
- true if the given message level is currently being logged.
-
entering
Log a method entry.This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY", log level FINER, and the given sourceMethod and sourceClass is logged.
-
entering
Log a method entry, with one parameter.This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY {0}", log level FINER, and the given sourceMethod, sourceClass, and parameter is logged.
-
entering
Log a method entry, with an array of parameters.This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY" (followed by a format {N} indicator for each entry in the parameter array), log level FINER, and the given sourceMethod, sourceClass, and parameters is logged.
-
exiting
Log a method return.This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN", log level FINER, and the given sourceMethod and sourceClass is logged.
-
exiting
Log a method return, with result object.This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN {0}", log level FINER, and the gives sourceMethod, sourceClass, and result object is logged.
-
throwing
Log throwing an exception.This is a convenience method to log that a method is terminating by throwing an exception. The logging is done using the FINER level.
If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers. The LogRecord's message is set to "THROW".
Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.
-
severe
Log a SEVERE message.If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.
-
warning
Log a WARNING message.If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.
-
info
Log an INFO message.If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.
-
config
Log a CONFIG message.If the logger is currently enabled for the CONFIG message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
log
Log a message.If the logger is currently enabled for the message level then the given message, and the exception dump, is forwarded to all the registered output Handler objects.
-
fine
Log a message.If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
-
fine
Log a FINE message.If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
-
fine
Log a FINE message.If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
-
fine
Log a FINE message.If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
-
fine
Log a FINE message.If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
-
finer
Log a FINER message.If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
-
finer
Log a FINER message.If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
-
finer
Log a FINER message.If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
-
finer
Log a FINER message.If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
-
finer
Log a FINER message.If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
-
finest
Log a FINEST message.If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
-
finest
Log a FINEST message.If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
-
finest
Log a FINEST message.If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
-
finest
Log a FINEST message.If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
-
finest
Log a FINEST message.If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
-
getName
Get the name for this logger. -
toString
Prepare a printable version of this instance. -
getMessage
This method returns a string from the bundle file if possible, treating the message argument as the key. If no such key is found in the bundle, the message itself is returned.- Parameters:
message- the message which is used as a key to search the bundle- Returns:
- a message either used as itself or searched in the bundle file.
-
getMessageWithPrefix
This method returns a string with a formatted prefix which depends on the level.- Parameters:
level- the level to printmessage- the message to print- Returns:
- a formatted string with a level prefix.
- See Also:
-
logInternal
This method does the actual logging. It is expected that if a check for isLoggable is desired for performance reasons, it has already been done, as it should not be done here.- Parameters:
level- the level to printmessage- the message to print
-