|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mcdermottroe.exemplar.ui.Log
public final class Log
A single point of entry for all logging within the program.
To set up the program for logging (this should be done within a UI):
// Create aHandlerHandlerhandler = new MyCustomHandler(); // Register theHandlerwith this class Log.registerHandler(Handler handler);
To publish log messages, simply pick the level of message you wish to send and use the corresponding method. For example, to publish a warning:
Log.warning("The foo subsystem is almost out of memory!");
Conversion table between log levels in this class and the Levels
in the java.util.logging package.
| Method in this class | Log Level produced |
|---|---|
error(CharSequence...) |
Level.SEVERE |
warning(CharSequence...) |
Level.WARNING |
info(CharSequence...) |
Level.INFO |
debug(CharSequence...) |
Level.FINE |
| Field Summary | |
|---|---|
private Logger |
logger
The underlying Logger through which all logging will flow. |
private static Log |
logInst
The singleton instance for this class. |
| Constructor Summary | |
|---|---|
private |
Log()
Constructor for the singleton object. |
| Method Summary | |
|---|---|
private static StackTraceElement |
caller()
Find the method and class from where the "outer" method of this class was called. |
static void |
clearHandlers()
Clear all Handlers from the underlying logger. |
static void |
debug(CharSequence... messages)
Log a debugging message. |
static void |
debug(Throwable cause,
CharSequence... messages)
Log a debug message about an exception. |
private static void |
doLog(CharSequence[] m,
Throwable t,
Level l)
Convenient form for doLog(LogRecord). |
private static void |
doLog(LogRecord logRecord)
Actual work of logging is done here. |
static void |
error(CharSequence... messages)
Log an error message. |
static void |
error(Throwable cause,
CharSequence... messages)
Log an error message with the exception that caused the error. |
static LogLevel |
getLevel()
Get the current LogLevel of the underlying Logger. |
private Logger |
getLogger()
Get the underlying Logger. |
static void |
info(CharSequence... messages)
Log an informational message about an exception which occurred and has been either successfully dealt with or ignored. |
static void |
registerHandler(Handler handler)
Register a Handler as the destination for all log messages. |
static void |
setLevel(LogLevel level)
Set the LogLevel of logging to something other than the default. |
static void |
warning(CharSequence... messages)
Log a warning message. |
static void |
warning(Throwable cause,
CharSequence... messages)
Log a warning message with the exception that caused the problem. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final Log logInst
private final Logger logger
Logger through which all logging will flow.
| Constructor Detail |
|---|
private Log()
| Method Detail |
|---|
private Logger getLogger()
Logger.
Logger.public static void registerHandler(Handler handler)
Handler as the destination for all log messages.
handler - The Handler which all log messages should be
passed to.public static void clearHandlers()
Handlers from the underlying logger.
public static LogLevel getLevel()
LogLevel of the underlying Logger.
LogLevel.public static void setLevel(LogLevel level)
LogLevel of logging to something other than the default.
level - The lowest LogLevel of message which should be
logged.public static void error(CharSequence... messages)
messages - The error message to log.
public static void error(Throwable cause,
CharSequence... messages)
messages - The error message to log.cause - The Exception that caused the error
condition.public static void warning(CharSequence... messages)
messages - The warning message to log.
public static void warning(Throwable cause,
CharSequence... messages)
messages - The warning message to log.cause - The Exception that caused the problem.public static void info(CharSequence... messages)
messages - The informational message to log.public static void debug(CharSequence... messages)
messages - The debug message to log.
public static void debug(Throwable cause,
CharSequence... messages)
messages - The debug message to log.cause - The Exception which caused the problem.
private static void doLog(CharSequence[] m,
Throwable t,
Level l)
doLog(LogRecord).
m - The message to log.t - If the message is being logged in response to an Exception, then the exception may be passed here.l - The Level at which the message is to be logged.private static void doLog(LogRecord logRecord)
logRecord - The LogRecord to log.private static StackTraceElement caller()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||