com.wutka.util
Class FileLogger

java.lang.Object
  |
  +--com.wutka.util.FileLogger
All Implemented Interfaces:
LogClient

public class FileLogger
extends java.lang.Object
implements LogClient

Writes log messages to a file.


Field Summary
protected  java.io.PrintWriter writer
           
 
Constructor Summary
FileLogger(java.lang.String filename, LogSeverity minLoggingLevel)
          Creates a file logger that will log events for all subsystems.
FileLogger(java.lang.String filename, java.lang.String subsystem, LogSeverity minLoggingLevel)
          Creates a file logger that logs messages for a specific subsystem.
 
Method Summary
 void logBytes(LogSeverity severity, java.lang.String subsystem, java.lang.String message, byte[] data, int offset, int length)
          Logs an exception and a text message to the file
 void logException(LogSeverity severity, java.lang.String subsystem, java.lang.String message, java.lang.Exception exc)
          Logs an exception and a text message to the file
 void logMessage(LogSeverity severity, java.lang.String subsystem, java.lang.String message)
          Logs a text message to the file
protected  void writeHeader(LogSeverity severity, java.lang.String subsystem)
          Writes a header into the file
protected  void writeTrailer(LogSeverity severity, java.lang.String subsystem)
          Writes a header into the file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected java.io.PrintWriter writer
Constructor Detail

FileLogger

public FileLogger(java.lang.String filename,
                  LogSeverity minLoggingLevel)
           throws java.io.IOException
Creates a file logger that will log events for all subsystems.
Parameters:
filename - The name of the file to write log messages to
minLoggingLevel - The minimum severity of events to log.
Throws:
java.io.IOException - if there is an error opening the log file

FileLogger

public FileLogger(java.lang.String filename,
                  java.lang.String subsystem,
                  LogSeverity minLoggingLevel)
           throws java.io.IOException
Creates a file logger that logs messages for a specific subsystem.
Parameters:
filename - The name of the file to write log messages to
subsystem - The subsystem whose messages will be logged
minLoggingLevel - The minimum severity of events to log.
Throws:
java.io.IOException - if there is an error opening the log file
Method Detail

logMessage

public void logMessage(LogSeverity severity,
                       java.lang.String subsystem,
                       java.lang.String message)
Logs a text message to the file
Specified by:
logMessage in interface LogClient
Parameters:
severity - The severity of the message
subsystem - The subsystem the message is for
message - The message to be logged

logException

public void logException(LogSeverity severity,
                         java.lang.String subsystem,
                         java.lang.String message,
                         java.lang.Exception exc)
Logs an exception and a text message to the file
Specified by:
logException in interface LogClient
Parameters:
severity - The severity of the message
subsystem - The subsystem the message is for
message - The message to be logged
exception - The exception to be logged

logBytes

public void logBytes(LogSeverity severity,
                     java.lang.String subsystem,
                     java.lang.String message,
                     byte[] data,
                     int offset,
                     int length)
Logs an exception and a text message to the file
Specified by:
logBytes in interface LogClient
Parameters:
severity - The severity of the message
subsystem - The subsystem the message is for
message - The message to be logged
data - The bytes to be logged
offset - The offset of the first byte to be logged
length - The number of bytes to log

writeHeader

protected void writeHeader(LogSeverity severity,
                           java.lang.String subsystem)
Writes a header into the file
Parameters:
severity - The severity of the message
subsystem - The subsystem this message belongs to

writeTrailer

protected void writeTrailer(LogSeverity severity,
                            java.lang.String subsystem)
Writes a header into the file
Parameters:
severity - The severity of the message
subsystem - The subsystem this message belongs to