org.opencyc.util
Class Log

java.lang.Object
  |
  +--org.opencyc.util.Log

public class Log
extends java.lang.Object


Field Summary
static Log current
          Current log instance.
protected static java.lang.String DEFAULT_LOG_FILENAME
          Default file name for the log file.
protected  boolean ignore
          If true, ignore all messages.
protected  java.lang.String logFilePath
          File pathname for the log file.
protected  java.io.PrintWriter printWriter
          PrintWriter object for the log file.
protected  java.io.BufferedWriter writer
          BufferedWriter object for the log file.
protected  boolean writeToErr
          If true, write error messages to System.err.
protected  boolean writeToFile
          If true, write messages to the log file.
protected  boolean writeToOut
          If true, write messages to System.out.
 
Constructor Summary
Log()
          Constructs a new Log object.
Log(java.lang.String logFilePath)
          Constructs a new Log object given the path.
Log(java.lang.String logFilePath, boolean writeToFile, boolean writeToErr, boolean writeToOut, boolean ignore)
          Constructs a new Log object given all parameters.
 
Method Summary
 void close()
          Closes the log file.
 void errorPrintln(java.lang.String errorMessage)
          Writes the error message to the log.
 java.lang.String getStorageLocation()
          Returns the path of the log file.
static void makeLog()
          Constructs a new Log object and store a reference to it at the Log class.
 void print(java.lang.String message)
          Writes the String message to the log.
 void println()
          Writes a newline to the log.
 void println(int message)
          Writes the int message to the log.
 void println(java.lang.String message)
          Writes the String message to the log.
 void printStackTrace(java.lang.Exception exception)
          Writes the exception stack trace to the log.
static void setCurrent(Log log)
          Sets the current log instance.
 void setStorageLocation(java.lang.String location)
          Sets the log file path to the specified location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

public static Log current
Current log instance. For convenience in calling, an instance of the Log is kept at by the class. Static methods are forwarded to the current instance so that users of the log need not keep track of the log instance themselves.

writeToFile

protected boolean writeToFile
If true, write messages to the log file.

writeToErr

protected boolean writeToErr
If true, write error messages to System.err.

writeToOut

protected boolean writeToOut
If true, write messages to System.out.

ignore

protected boolean ignore
If true, ignore all messages.

logFilePath

protected java.lang.String logFilePath
File pathname for the log file.

printWriter

protected java.io.PrintWriter printWriter
PrintWriter object for the log file.

writer

protected java.io.BufferedWriter writer
BufferedWriter object for the log file.

DEFAULT_LOG_FILENAME

protected static final java.lang.String DEFAULT_LOG_FILENAME
Default file name for the log file.
Constructor Detail

Log

public Log()
Constructs a new Log object. Display all messages only to the default log file "agent.log".

Log

public Log(java.lang.String logFilePath)
Constructs a new Log object given the path. Display all messages.
Parameters:
logFilePath - specifies the path for the log file.

Log

public Log(java.lang.String logFilePath,
           boolean writeToFile,
           boolean writeToErr,
           boolean writeToOut,
           boolean ignore)
Constructs a new Log object given all parameters.
Parameters:
logFilePath - specifies the path for the log file.
writeToFile - if true, write messages to the log file.
writeToErr - if true, write error messages to System.err.
writeToOut - if true, write messages to System.out.
ignore - if true, ignore all messages.
Method Detail

makeLog

public static void makeLog()
Constructs a new Log object and store a reference to it at the Log class.

setStorageLocation

public void setStorageLocation(java.lang.String location)
                        throws java.io.IOException
Sets the log file path to the specified location.

getStorageLocation

public java.lang.String getStorageLocation()
Returns the path of the log file.

println

public void println(int message)
Writes the int message to the log.
Parameters:
message - the int message to be logged.

println

public void println()
Writes a newline to the log.

print

public void print(java.lang.String message)
Writes the String message to the log.
Parameters:
message - the String message to be logged.

println

public void println(java.lang.String message)
Writes the String message to the log.
Parameters:
message - the String message to be logged.

errorPrintln

public void errorPrintln(java.lang.String errorMessage)
Writes the error message to the log.
Parameters:
errorMessage - the error message to be logged.

printStackTrace

public void printStackTrace(java.lang.Exception exception)
Writes the exception stack trace to the log.
Parameters:
exception - the exception to be reported.

close

public void close()
Closes the log file.

setCurrent

public static void setCurrent(Log log)
Sets the current log instance.
Parameters:
log - a log object.