The Meta-Environment API

toolbus.logging
Class FileLogger

java.lang.Object
  extended by toolbus.logging.FileLogger
All Implemented Interfaces:
ILogger

public class FileLogger
extends java.lang.Object
implements ILogger

Logger implementation that writes to a file.

Author:
Arnold Lankamp

Field Summary
private static java.lang.String endLineCharacter
           
private  int level
           
private  boolean timestamp
           
private  java.io.PrintWriter writer
           
 
Fields inherited from interface toolbus.logging.ILogger
ALL, DEBUG, DEBUGSTR, ERROR, ERRORSTR, FATAL, FATALSTR, INFO, INFOSTR, LOG, LOGSTR, OFF, UNKNOWNSTR, WARNING, WARNINGSTR
 
Constructor Summary
FileLogger()
          Default constructor.
FileLogger(int level)
          Constructor.
 
Method Summary
 void finalize()
          Closes this logger.
 void log(java.lang.String message, int loglevel)
          Logs the given message (but only if the message is 'important' enough).
 void log(java.lang.String message, java.lang.Throwable throwable, int loglevel)
          Logs the given message, including the given stacktrace (but only if the message is 'important' enough).
 void setTimestamp(boolean on)
          Toggle timestamp printing in messages
private  boolean shouldLog(int loglevel)
          Method for checking if we should log a message.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endLineCharacter

private static final java.lang.String endLineCharacter

level

private final int level

writer

private final java.io.PrintWriter writer

timestamp

private boolean timestamp
Constructor Detail

FileLogger

FileLogger()
Default constructor. Inititalizes this logger with the default log level (WARNING).


FileLogger

FileLogger(int level)
Constructor. Initialized this logger with the given log level.

Parameters:
level - The log level to initialize this logger with.
Method Detail

shouldLog

private boolean shouldLog(int loglevel)
Method for checking if we should log a message. This depends on the log level and the given log level.

Parameters:
loglevel - The log level of the message.
Returns:
True if we should log the message with the given log level, false otherwise.

setTimestamp

public void setTimestamp(boolean on)
Description copied from interface: ILogger
Toggle timestamp printing in messages

Specified by:
setTimestamp in interface ILogger
Parameters:
on - Sets timestamp on or off.

log

public void log(java.lang.String message,
                int loglevel)
Description copied from interface: ILogger
Logs the given message (but only if the message is 'important' enough).

Specified by:
log in interface ILogger
Parameters:
message - The message that needs to be logged.
loglevel - The log level of the message.
See Also:
ILogger.log(String, int)

log

public void log(java.lang.String message,
                java.lang.Throwable throwable,
                int loglevel)
Description copied from interface: ILogger
Logs the given message, including the given stacktrace (but only if the message is 'important' enough).

Specified by:
log in interface ILogger
Parameters:
message - The message that needs to be logged.
throwable - The stacktrace associated with the message.
loglevel - The log level of the message.
See Also:
ILogger.log(String, Throwable, int)

finalize

public void finalize()
Closes this logger.

Overrides:
finalize in class java.lang.Object

The Meta-Environment API