|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.rice.cs.util.Log
public class Log
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.
Field Summary | |
---|---|
protected File |
_file
The file object for this log. |
protected boolean |
_isEnabled
Whether this particular log is enabled in development mode. |
protected String |
_name
The filename of this log. |
protected PrintWriter |
_writer
PrintWriter to print messages to a file. |
static SimpleDateFormat |
DATE_FORMAT
|
static boolean |
ENABLE_ALL
|
Constructor Summary | |
---|---|
Log(File f,
boolean isEnabled)
|
|
Log(String name,
boolean isEnabled)
Creates a new Log with the given name. |
Method Summary | |
---|---|
protected void |
_init()
Creates the log file, if enabled. |
void |
close()
Closes a log file. |
boolean |
isEnabled()
Returns whether this log is currently enabled. |
void |
log(String message)
Prints a message to the log, if enabled. |
void |
log(String s,
StackTraceElement[] trace)
Prints a message and exception stack trace to the log, if enabled. |
void |
log(String s,
Throwable t)
Prints a message and exception stack trace to the log, if enabled. |
void |
setEnabled(boolean isEnabled)
Sets whether this log is enabled. |
static String |
traceToString(StackTraceElement[] trace)
Converts a stack trace (StackTraceElement[]) to string form |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean ENABLE_ALL
protected volatile boolean _isEnabled
protected volatile String _name
protected volatile File _file
protected volatile PrintWriter _writer
public static final SimpleDateFormat DATE_FORMAT
Constructor Detail |
---|
public Log(String name, boolean isEnabled)
name
- File name for the logisEnabled
- Whether to actively use this logpublic Log(File f, boolean isEnabled)
Method Detail |
---|
protected void _init()
public void setEnabled(boolean isEnabled)
isEnabled
- Whether to print messages to the log filepublic boolean isEnabled()
public void log(String message)
message
- Message to print.public static String traceToString(StackTraceElement[] trace)
public void log(String s, StackTraceElement[] trace)
s
- Message to printtrace
- Stack track to logpublic void log(String s, Throwable t)
s
- Message to printt
- Throwable to logpublic void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |