|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcage.core.Logger
public class Logger
This simple logging system is modeled after the fuctionality of log4j
but only includes the features needed for CAGE.
A static logger named rootLogger can be access via getRootLogger
.
The static logger by default prints to System.out
and is at
ERROR level. By default, all loggers take the level and printing target from
the root logger. In general, classes can simply keep a reference to the rootLogger
and print to that, but instances of Logger can be created if you want to have
different levels of reporting between classes or if you want to have one class
print to a different stream than the root logger.
The static message strings, debugMessage
, infoMessage
,
and errorMessage
are prepended to all logger output of the respective
levels. The defaults can be replaced with custom strings via the setters.
Nested Class Summary | |
---|---|
static class |
Logger.Level
Constants for the Level of the logger. |
Field Summary | |
---|---|
static boolean |
guiMode
If true, error level messages will be displayed in GUI Dialogs |
Constructor Summary | |
---|---|
Logger()
Creates a default logger |
|
Logger(Logger.Level level)
Creates a logger which the specified level but default print stream. |
|
Logger(java.io.PrintStream out)
Creates a logger that uses the provided Printstream for output |
|
Logger(java.io.PrintStream out,
Logger.Level level)
Creates a logger with a custom print stream and level |
Method Summary | |
---|---|
void |
debug(java.lang.Object obj)
Print a debug message |
void |
debug(java.lang.Object obj,
java.lang.Throwable t)
Print a debug message |
void |
error(java.lang.Object obj)
Print a error message |
void |
error(java.lang.Object obj,
java.lang.Throwable t)
Print a error message |
static java.lang.String |
getDebugMessage()
Gets the message. |
static java.lang.String |
getErrorMessage()
Gets the message. |
static int |
getIndent()
Gets the indent amount for all loggers. |
static java.lang.String |
getInfoMessage()
Gets the message. |
Logger.Level |
getLevel()
The level of output allowed |
java.io.PrintStream |
getOut()
Returns the output stream |
static Logger |
getRootLogger()
Gets the static logger all loggers grow from. |
void |
info(java.lang.Object obj)
Print a info message |
void |
info(java.lang.Object obj,
java.lang.Throwable t)
Print a info message |
static void |
setDebugMessage(java.lang.String debugMessage)
Sets the message. |
static void |
setErrorMessage(java.lang.String errorMessage)
Sets the message. |
static void |
setIndent(int indent)
Sets the indent amount in spaces. |
static void |
setInfoMessage(java.lang.String infoMessage)
Sets the message. |
void |
setLevel(Logger.Level level)
Sets the output level |
void |
setOut(java.io.PrintStream out)
Sets the stream the logger writes to |
static void |
setRootLogger(Logger rootLogger)
Allows replacement of the root logger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean guiMode
Constructor Detail |
---|
public Logger()
public Logger(java.io.PrintStream out)
out
- Stream to write the log to.public Logger(Logger.Level level)
level
- Level to set the logger to.public Logger(java.io.PrintStream out, Logger.Level level)
out
- Stream to write the log to.level
- Level to set the logger to.Method Detail |
---|
public void debug(java.lang.Object obj)
obj
- Object to printpublic void debug(java.lang.Object obj, java.lang.Throwable t)
obj
- Object to printt
- A throwable object, often the exception you are loggingpublic void info(java.lang.Object obj)
obj
- Object to printpublic void info(java.lang.Object obj, java.lang.Throwable t)
obj
- Object to printt
- A throwable object, often the exception you are loggingpublic void error(java.lang.Object obj)
obj
- Object to printpublic void error(java.lang.Object obj, java.lang.Throwable t)
obj
- Object to printt
- A throwable object, often the exception you are loggingpublic static java.lang.String getDebugMessage()
public static void setDebugMessage(java.lang.String debugMessage)
debugMessage
- The message prepended to all debug messages.public static java.lang.String getErrorMessage()
public static void setErrorMessage(java.lang.String errorMessage)
errorMessage
- The message prepended to all error messages.public static java.lang.String getInfoMessage()
public static void setInfoMessage(java.lang.String infoMessage)
infoMessage
- The message prepended to all info messages.public Logger.Level getLevel()
public void setLevel(Logger.Level level)
level
- level to set this logger topublic java.io.PrintStream getOut()
public void setOut(java.io.PrintStream out)
out
- The stream to write to.public static int getIndent()
public static void setIndent(int indent)
indent
- number of spaces to indentpublic static Logger getRootLogger()
public static void setRootLogger(Logger rootLogger)
rootLogger
- logger to replace the root logger.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |