|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.go.trove.log.Log
General purpose logging class that operates using a hierarchy of Logs and an event model. All LogEvents are categorized into one of four types: debugging, informational, warning and error. A log event can be generated by writing to one of the four PrintWriter fields provided (debug, info, warn and error), or by calling the debug, info, warn or error methods. Logs can have a parent Log, which by default, receives all the events that the Log generates or receives. If a log is disabled, it will not generate or propagate events. Examples:
Log log = new Log("test", null);
log.addLogListener(new LogScribe(new PrintWriter(System.out)));
log.debug().println("Printing a debugging message");
log.info("System running");
Syslog.info().println("Creating child log...");
Log child = new Log("child", Syslog.log);
child.warn("This is a system warning...");
try {
...
}
catch (Exception e) {
child.error(e);
}
Log saved = new Log("saved", Syslog.log);
File logDir = new File("/logs/");
OutputStream out = new DailyFileLogStream(logDir);
saved.addLogListener(new LogScribe(new PrintWriter(out)));
saved.info("Saved log file initialized");
LogScribe,
Syslog,
LogEventParsingWriter,
DailyFileLogStream, Serialized Form| Constructor Summary | |
Log(java.lang.String name,
Log parent)
Create a new Log that inherits enabled settings from its parent. |
|
| Method Summary | |
void |
addLogListener(LogListener listener)
|
void |
addRootLogListener(LogListener listener)
adds a listener to the root log, the log with a null parent |
void |
applyProperties(java.util.Map properties)
Understands and applies the following boolean properties. |
java.io.PrintWriter |
debug()
Returns a PrintWriter for debug messages. |
void |
debug(java.lang.String s)
Simple method for logging a single debugging message. |
void |
debug(java.lang.Throwable t)
Simple method for logging a single debugging exception. |
java.io.PrintWriter |
error()
Returns a PrintWriter for error messages. |
void |
error(java.lang.String s)
Simple method for logging a single error message. |
void |
error(java.lang.Throwable t)
Simple method for logging a single error exception. |
Log[] |
getChildren()
Returns a copy of the children Logs. |
java.lang.String |
getDescription()
Returns a brief description of this Log. |
java.lang.String |
getName()
Returns null if this Log has no name. |
java.io.PrintWriter |
info()
Returns a PrintWriter for information messages. |
void |
info(java.lang.String s)
Simple method for logging a single information message. |
void |
info(java.lang.Throwable t)
Simple method for logging a single information exception. |
boolean |
isDebugEnabled()
Returns true if debug events for this Log are enabled. |
boolean |
isEnabled()
Returns true if this Log is enabled. |
boolean |
isErrorEnabled()
Returns true if error events for this Log are enabled. |
boolean |
isInfoEnabled()
Returns true if info events for this Log are enabled. |
boolean |
isWarnEnabled()
Returns true if warn events for this Log are enabled. |
void |
logException(LogEvent e)
If this Log is enabled, then dispatch the LogEvent to all of its listeners as a logged exception. |
void |
logMessage(LogEvent e)
If this Log is enabled, then dispatch the LogEvent to all of its listeners as a logged message. |
void |
removeLogListener(LogListener listener)
|
void |
removeRootLogListener(LogListener listener)
|
void |
setDebugEnabled(boolean enabled)
When debug is enabled, this Log is enabled and all parent Logs are enabled. |
void |
setDescription(java.lang.String desc)
Set the log's description text. |
void |
setEnabled(boolean enabled)
When this Log is enabled, all parent Logs are also enabled. |
void |
setErrorEnabled(boolean enabled)
When error is enabled, this Log is enabled and all parent Logs are enabled. |
void |
setInfoEnabled(boolean enabled)
When info is enabled, this Log is enabled and all parent Logs are enabled. |
void |
setWarnEnabled(boolean enabled)
When warn is enabled, this Log is enabled and all parent Logs are enabled. |
java.lang.String |
toString()
Returns a short description of this log. |
java.io.PrintWriter |
warn()
Returns a PrintWriter for warning messages. |
void |
warn(java.lang.String s)
Simple method for logging a single warning message. |
void |
warn(java.lang.Throwable t)
Simple method for logging a single warning exception. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Log(java.lang.String name,
Log parent)
name - The optional name of this Log.parent - The parent Log that will be added as a LogListener to this
Log. If null, then this Log has no parent Log.| Method Detail |
public void addRootLogListener(LogListener listener)
public void removeRootLogListener(LogListener listener)
public void addLogListener(LogListener listener)
public void removeLogListener(LogListener listener)
public void logMessage(LogEvent e)
logMessage in interface LogListenerpublic void logException(LogEvent e)
logException in interface LogListenerpublic java.io.PrintWriter debug()
public void debug(java.lang.String s)
public void debug(java.lang.Throwable t)
public java.io.PrintWriter info()
public void info(java.lang.String s)
public void info(java.lang.Throwable t)
public java.io.PrintWriter warn()
public void warn(java.lang.String s)
public void warn(java.lang.Throwable t)
public java.io.PrintWriter error()
public void error(java.lang.String s)
public void error(java.lang.Throwable t)
public Log[] getChildren()
public java.lang.String getName()
public java.lang.String getDescription()
public void setDescription(java.lang.String desc)
public boolean isEnabled()
public void setEnabled(boolean enabled)
public boolean isDebugEnabled()
public void setDebugEnabled(boolean enabled)
public boolean isInfoEnabled()
public void setInfoEnabled(boolean enabled)
public boolean isWarnEnabled()
public void setWarnEnabled(boolean enabled)
public boolean isErrorEnabled()
public void setErrorEnabled(boolean enabled)
public void applyProperties(java.util.Map properties)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||