| java.lang.Object snaq.util.LogUtil
All known Subclasses: snaq.util.ObjectPool, snaq.db.ConnectionPoolManager,
LogUtil | public class LogUtil (Code) | | Base class providing simple logging and debug functionality, which can
either be instantiated and used as a logging object, or can be sub-classed
to be used as an integral logging facility.
When specifying an OutputStream for use by the Logger, make sure that none
of the "standard" streams are used (System.out, System.err) as
they will be closed either when the close() method is called or the Logger
terminates. To send log to the standard output stream simply call
setLogging(true) and leave the actual log unspecified.
author: Giles Winstanley |
Constructor Summary | |
public | LogUtil() Creates a new Logger with logging disabled. | public | LogUtil(File f) Creates a new Logger which writes to the specified file. |
Method Summary | |
public synchronized void | close() Closes the log. | public PrintStream | getLogStream() Returns the current PrintStream used to write to the log. | public boolean | isDebug() Returns whether debug logging is enabled. | public boolean | isLogging() Returns whether logging is enabled. | public synchronized void | log(String prefix, String logEntry) Writes a message to the log, with an optional prefix. | public void | log(String logEntry) Writes a message to the log. | public void | log(Throwable e, String prefix, String logEntry) Writes a message with an Exception to the log file. | public void | log(Throwable e, String logEntry) Writes a message with an Exception to the log file. | public void | log(Throwable e) Writes an Exception to the log file. | public synchronized void | setDateFormat(DateFormat df) Sets the date formatter for the logging. | public void | setDebug(boolean b) Determines whether to perform debug logging. | public synchronized void | setLog(OutputStream out) Sets the log stream and enables logging. | public synchronized void | setLog(PrintStream ps) Sets the log writer and enables logging. | public void | setLogging(boolean b) Determines whether to write to the log. |
debug | protected boolean debug(Code) | | |
logging | protected boolean logging(Code) | | |
LogUtil | public LogUtil()(Code) | | Creates a new Logger with logging disabled.
|
close | public synchronized void close()(Code) | | Closes the log.
|
getLogStream | public PrintStream getLogStream()(Code) | | Returns the current PrintStream used to write to the log.
|
isDebug | public boolean isDebug()(Code) | | Returns whether debug logging is enabled.
|
isLogging | public boolean isLogging()(Code) | | Returns whether logging is enabled.
|
log | public synchronized void log(String prefix, String logEntry)(Code) | | Writes a message to the log, with an optional prefix.
|
log | public void log(String logEntry)(Code) | | Writes a message to the log.
|
log | public void log(Throwable e, String logEntry)(Code) | | Writes a message with an Exception to the log file.
|
setDateFormat | public synchronized void setDateFormat(DateFormat df)(Code) | | Sets the date formatter for the logging.
|
setDebug | public void setDebug(boolean b)(Code) | | Determines whether to perform debug logging.
|
setLog | public synchronized void setLog(OutputStream out)(Code) | | Sets the log stream and enables logging.
|
setLog | public synchronized void setLog(PrintStream ps)(Code) | | Sets the log writer and enables logging.
|
setLogging | public void setLogging(boolean b)(Code) | | Determines whether to write to the log.
|
|
|