edu.wpi.prc.persistence
Class SysLogger

java.lang.Object
  extended by edu.wpi.prc.persistence.SysLogger

public class SysLogger
extends java.lang.Object

Sends output to a log file or to System.err if no log file has been configured.

Author:
James Baldassari

Field Summary
private static java.lang.String DEFAULT_LOG_DIR
           
private static java.lang.String DEFAULT_LOG_PATH
           
private static java.lang.String LOG_TIMESTAMP_FORMAT
           
private  java.io.File logFile
           
private  java.io.FileOutputStream logFileStream
           
private static SysLogger logger
           
private  java.io.PrintStream logStream
           
private static java.text.SimpleDateFormat timestampFormat
           
 
Constructor Summary
private SysLogger()
          Private constructor.
 
Method Summary
static void initialize()
          Opens the default log file for appending and initializes the streams.
static void initialize(java.lang.String logPath)
          Opens the log file for appending and initializes the streams.
static void print(java.lang.String str)
          Writes the given string to the log file.
static void println(java.lang.String str)
          Writes the given string to the log file, then writes a new line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static SysLogger logger

DEFAULT_LOG_DIR

private static final java.lang.String DEFAULT_LOG_DIR
See Also:
Constant Field Values

DEFAULT_LOG_PATH

private static final java.lang.String DEFAULT_LOG_PATH

LOG_TIMESTAMP_FORMAT

private static final java.lang.String LOG_TIMESTAMP_FORMAT

timestampFormat

private static java.text.SimpleDateFormat timestampFormat

logFile

private java.io.File logFile

logFileStream

private java.io.FileOutputStream logFileStream

logStream

private java.io.PrintStream logStream
Constructor Detail

SysLogger

private SysLogger()
Private constructor.

Method Detail

initialize

public static void initialize()
                       throws InvalidLogPathException
Opens the default log file for appending and initializes the streams.

Throws:
InvalidLogPathException

initialize

public static void initialize(java.lang.String logPath)
                       throws InvalidLogPathException
Opens the log file for appending and initializes the streams.

Parameters:
logPath - The path to the log file.
Throws:
InvalidLogPathException

print

public static void print(java.lang.String str)
Writes the given string to the log file. If the SysLogger has not been initialized this method will instead print the string to System.err. NOTE: initialize() must be called first or print() will have no effect.

Parameters:
str - The string to write.

println

public static void println(java.lang.String str)
Writes the given string to the log file, then writes a new line. If the logger has not been initialized this method will instead print the string to System.err. NOTE: initialize() must be called first or println() will have no effect.

Parameters:
str - The string to write.