Class AbstractLogger
- java.lang.Object
-
- com.sun.jdo.spi.persistence.utility.logging.AbstractLogger
-
- All Implemented Interfaces:
Logger
- Direct Known Subclasses:
LoggerJDK13
public abstract class AbstractLogger extends Object implements Logger
This class provides a default implementation of the com.sun.jdo.spi.persistence.utility.logging.Logger interface which implements most methods and/or delegates them to a few abstract methods which subclasses must override.- Version:
- %I%
- Author:
- Rochelle Raccah
-
-
Constructor Summary
Constructors Constructor Description AbstractLogger(String loggerName, String bundleName, ClassLoader loader)
Creates a new AbstractLogger.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
config(String msg)
Log a CONFIG message.void
entering(String sourceClass, String sourceMethod)
Log a method entry.void
entering(String sourceClass, String sourceMethod, Object param1)
Log a method entry, with one parameter.void
entering(String sourceClass, String sourceMethod, Object[] params)
Log a method entry, with an array of parameters.void
exiting(String sourceClass, String sourceMethod)
Log a method return.void
exiting(String sourceClass, String sourceMethod, Object result)
Log a method return, with result object.void
fine(String msg)
Log a message.void
fine(String msg, Object o1)
Log a FINE message.void
fine(String msg, Object[] o)
Log a FINE message.void
fine(String msg, Object o1, Object o2)
Log a FINE message.void
fine(String msg, Object o1, Object o2, Object o3)
Log a FINE message.void
finer(String msg)
Log a FINER message.void
finer(String msg, Object o1)
Log a FINER message.void
finer(String msg, Object[] o)
Log a FINER message.void
finer(String msg, Object o1, Object o2)
Log a FINER message.void
finer(String msg, Object o1, Object o2, Object o3)
Log a FINER message.void
finest(String msg)
Log a FINEST message.void
finest(String msg, Object o1)
Log a FINEST message.void
finest(String msg, Object[] o)
Log a FINEST message.void
finest(String msg, Object o1, Object o2)
Log a FINEST message.void
finest(String msg, Object o1, Object o2, Object o3)
Log a FINEST message.protected ResourceBundle
getBundle()
Get the message bundle for the named instance of the logger.int
getLevel()
protected String
getMessage(String message)
This method returns a string from the bundle file if possible, treating the message argument as the key.protected static ResourceBundle
getMessages()
Get the message bundle for the AbstractLogger itself.protected String
getMessageWithPrefix(int level, String message)
This method returns a string with a formatted prefix which depends on the level.String
getName()
Get the name for this logger.void
info(String msg)
Log an INFO message.boolean
isLoggable()
Return whether logging is enabled at the FINE level.boolean
isLoggable(int levelValue)
Check if a message of the given level would actually be logged by this logger.void
log(int level, String msg)
Log a message.void
log(int level, String msg, Object o1)
Log a message.void
log(int level, String msg, Object[] o)
Log a message.void
log(int level, String msg, Object o1, Object o2)
Log a message.void
log(int level, String msg, Object o1, Object o2, Object o3)
Log a message.abstract void
log(int level, String msg, Throwable thrown)
Log a message.protected abstract void
logInternal(int level, String message)
This method does the actual logging.void
severe(String msg)
Log a SEVERE message.void
throwing(String sourceClass, String sourceMethod, Throwable thrown)
Log throwing an exception.String
toString()
Prepare a printable version of this instance.static String
toString(int level)
Return the string name of a level given its int value.void
warning(String msg)
Log a WARNING message.
-
-
-
Constructor Detail
-
AbstractLogger
public AbstractLogger(String loggerName, String bundleName, ClassLoader loader)
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 Detail
-
getMessages
protected static ResourceBundle getMessages()
Get the message bundle for the AbstractLogger itself.
-
toString
public static String toString(int level)
Return the string name of a level given its int value.- Returns:
- a string representing the level
-
getBundle
protected ResourceBundle 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:
isLoggable
in 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:
isLoggable
in interfaceLogger
- Parameters:
levelValue
- the level to check- Returns:
- true if the given message level is currently being logged.
-
entering
public void entering(String sourceClass, String sourceMethod)
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
public void entering(String sourceClass, String sourceMethod, Object param1)
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
public void entering(String sourceClass, String sourceMethod, Object[] params)
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
public void exiting(String sourceClass, String sourceMethod)
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
public void exiting(String sourceClass, String sourceMethod, Object result)
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
public void throwing(String sourceClass, String sourceMethod, Throwable thrown)
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
public void severe(String msg)
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
public void warning(String msg)
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
public void info(String msg)
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
public void config(String msg)
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
public void log(int level, String msg)
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
public void log(int level, String msg, Object o1)
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
public void log(int level, String msg, Object[] o)
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
public void log(int level, String msg, Object o1, Object o2)
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
public void log(int level, String msg, Object o1, Object o2, Object o3)
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
public abstract void log(int level, String msg, Throwable thrown)
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
public void fine(String msg)
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
public void fine(String msg, Object o1)
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
public void fine(String msg, Object[] o)
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
public void fine(String msg, Object o1, Object o2)
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
public void fine(String msg, Object o1, Object o2, Object o3)
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
public void finer(String msg)
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
public void finer(String msg, Object[] o)
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
public void finer(String msg, Object o1)
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
public void finer(String msg, Object o1, Object o2)
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
public void finer(String msg, Object o1, Object o2, Object o3)
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
public void finest(String msg)
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
public void finest(String msg, Object[] o)
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
public void finest(String msg, Object o1)
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
public void finest(String msg, Object o1, Object o2)
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
public void finest(String msg, Object o1, Object o2, Object o3)
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
public String getName()
Get the name for this logger.
-
toString
public String toString()
Prepare a printable version of this instance.
-
getMessage
protected String getMessage(String message)
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
protected String getMessageWithPrefix(int level, String message)
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:
toString(int)
-
logInternal
protected abstract void logInternal(int level, String message)
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
-
-