Class LocalDrinkLogger

java.lang.Object
  extended byLocalDrinkLogger
All Implemented Interfaces:
DrinkLoggerSpec

public class LocalDrinkLogger
extends Object
implements DrinkLoggerSpec

A basic class to perform logging for the drink software. Printing to a log is more desirable because it is much faster than printing to stdout, and it is persistent.

Version:
$Revision: #6 $
Author:
Sean M. Graham [grahams@csh.rit.edu], Kevin Thompson [antiduh@csh.rit.edu]

Field Summary
private  String filename
          The file that we are printing our log messages to.
private  PrintWriter out
          The PrintWriter that is connected the file that we are actually saving the log messages to.
 
Constructor Summary
LocalDrinkLogger(ConfigMgr configMgr)
          Reads the settings out of the configuration file and then constructs from that.
LocalDrinkLogger(String logFilename)
          A constructor which assumes demarcation by default.
LocalDrinkLogger(String logFilename, boolean printDemarc)
          Construct the class using the provided values instead of retrieving them from the configuration.
 
Method Summary
private  void initialize(String logFilename, boolean printDemarc)
          Initialize the LocalDrinkLogger by opening the file.
 void println(String message)
          Prints the specified message to the log file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

private String filename
The file that we are printing our log messages to.


out

private PrintWriter out
The PrintWriter that is connected the file that we are actually saving the log messages to.

Constructor Detail

LocalDrinkLogger

public LocalDrinkLogger(String logFilename,
                        boolean printDemarc)
Construct the class using the provided values instead of retrieving them from the configuration.

Parameters:
logFilename - The filename of the file to print the log messages to.
printDemarc - Whether or not to print the 'new session' demarcation.

LocalDrinkLogger

public LocalDrinkLogger(String logFilename)
A constructor which assumes demarcation by default. Provided for simple backwards compatability.

Parameters:
logFilename - The filename to write the log data to.

LocalDrinkLogger

public LocalDrinkLogger(ConfigMgr configMgr)
Reads the settings out of the configuration file and then constructs from that. Currently assumes that demarcation is to be done.

Parameters:
configMgr - Where to get our runtime configuration values.
Method Detail

initialize

private void initialize(String logFilename,
                        boolean printDemarc)
Initialize the LocalDrinkLogger by opening the file. If 'printDemarc' is true, then also print the line of '=' to signal the start of a new execution/log session. The file is flushed after every write so that if a problem occurs, the error is guaranteed to be written.

Parameters:
logFilename - The name of the file to store log messages in.
printDemarc - Whether or not to print bar that demarcates the start of a new server session. This is printed when the server starts up.

println

public void println(String message)
Prints the specified message to the log file. The message is always flushed to make sure that the message always gets to where it is going.

Specified by:
println in interface DrinkLoggerSpec
Parameters:
message - The message to print to the file.