public abstract class AbstractLogger extends Object implements Logger
Constructor and Description |
---|
AbstractLogger(String loggerName,
String bundleName,
ClassLoader loader)
Creates a new AbstractLogger.
|
Modifier and Type | Method and 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.
|
public AbstractLogger(String loggerName, String bundleName, ClassLoader loader)
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 fileprotected static ResourceBundle getMessages()
public static String toString(int level)
protected ResourceBundle getBundle()
public int getLevel()
public boolean isLoggable()
isLoggable
in interface Logger
public boolean isLoggable(int levelValue)
isLoggable
in interface Logger
levelValue
- the level to checkpublic void entering(String sourceClass, String sourceMethod)
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.
public void entering(String sourceClass, String sourceMethod, Object param1)
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.
public void entering(String sourceClass, String sourceMethod, Object[] params)
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.
public void exiting(String sourceClass, String sourceMethod)
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.
public void exiting(String sourceClass, String sourceMethod, Object result)
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.
public void throwing(String sourceClass, String sourceMethod, Throwable thrown)
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.
public void severe(String msg)
If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.
public void warning(String msg)
If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.
public void info(String msg)
If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.
public void config(String msg)
If the logger is currently enabled for the CONFIG message level then the given message is forwarded to all the registered output Handler objects.
public void log(int level, String msg)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public void log(int level, String msg, Object o1)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public void log(int level, String msg, Object[] o)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public void log(int level, String msg, Object o1, Object o2)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public void log(int level, String msg, Object o1, Object o2, Object o3)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public abstract void log(int level, String msg, Throwable thrown)
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.
public void fine(String msg)
If the logger is currently enabled for the message level then the given message is forwarded to all the registered output Handler objects.
public void fine(String msg, Object o1)
If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
public void fine(String msg, Object[] o)
If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
public void fine(String msg, Object o1, Object o2)
If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
public void fine(String msg, Object o1, Object o2, Object o3)
If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.
public void finer(String msg)
If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
public void finer(String msg, Object[] o)
If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
public void finer(String msg, Object o1)
If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
public void finer(String msg, Object o1, Object o2)
If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
public void finer(String msg, Object o1, Object o2, Object o3)
If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.
public void finest(String msg)
If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
public void finest(String msg, Object[] o)
If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
public void finest(String msg, Object o1)
If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
public void finest(String msg, Object o1, Object o2)
If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
public void finest(String msg, Object o1, Object o2, Object o3)
If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.
public String getName()
public String toString()
protected String getMessage(String message)
message
- the message which is used as a key to search the bundleprotected String getMessageWithPrefix(int level, String message)
level
- the level to printmessage
- the message to printtoString(int)
protected abstract void logInternal(int level, String message)
level
- the level to printmessage
- the message to printCopyright © 2018. All rights reserved.