| java.lang.Object edu.rice.cs.util.Log
Log | public class Log (Code) | | Logging class to record errors or unexpected behavior to a file. The file is created in the current directory,
and is only used if the log is enabled. All logs can be enabled at once with the ENABLE_ALL field.
version: $Id: Log.java 4255 2007-08-28 19:17:37Z mgricken $ |
Field Summary | |
final public static boolean | ENABLE_ALL | protected volatile File | _file The file object for this log. | protected volatile boolean | _isEnabled Whether this particular log is enabled in development mode. | protected volatile String | _name The filename of this log. | protected volatile PrintWriter | _writer PrintWriter to print messages to a file. |
Constructor Summary | |
public | Log(String name, boolean isEnabled) Creates a new Log with the given name. | public | Log(File f, boolean isEnabled) |
Method Summary | |
protected void | _init() Creates the log file, if enabled. | public boolean | isEnabled() Returns whether this log is currently enabled. | public synchronized void | log(String message) Prints a message to the log, if enabled. | public synchronized void | log(String s, StackTraceElement[] trace) Prints a message and exception stack trace to the log, if enabled. | public synchronized void | log(String s, Throwable t) Prints a message and exception stack trace to the log, if enabled. | public void | setEnabled(boolean isEnabled) Sets whether this log is enabled. | public static String | traceToString(StackTraceElement[] trace) |
ENABLE_ALL | final public static boolean ENABLE_ALL(Code) | | |
_file | protected volatile File _file(Code) | | The file object for this log.
|
_isEnabled | protected volatile boolean _isEnabled(Code) | | Whether this particular log is enabled in development mode.
|
_name | protected volatile String _name(Code) | | The filename of this log.
|
_writer | protected volatile PrintWriter _writer(Code) | | PrintWriter to print messages to a file.
|
Log | public Log(String name, boolean isEnabled)(Code) | | Creates a new Log with the given name. If enabled is true, a file is created in the current directory with the
given name.
Parameters: name - File name for the log Parameters: isEnabled - Whether to actively use this log |
_init | protected void _init()(Code) | | Creates the log file, if enabled.
|
isEnabled | public boolean isEnabled()(Code) | | Returns whether this log is currently enabled.
|
log | public synchronized void log(String message)(Code) | | Prints a message to the log, if enabled.
Parameters: message - Message to print. |
log | public synchronized void log(String s, StackTraceElement[] trace)(Code) | | Prints a message and exception stack trace to the log, if enabled.
Parameters: s - Message to print Parameters: trace - Stack track to log |
log | public synchronized void log(String s, Throwable t)(Code) | | Prints a message and exception stack trace to the log, if enabled.
Parameters: s - Message to print Parameters: t - Throwable to log |
setEnabled | public void setEnabled(boolean isEnabled)(Code) | | Sets whether this log is enabled. Only has an effect if the code is in development mode.
Parameters: isEnabled - Whether to print messages to the log file |
|
|