EAF 7.6 Implementation

com.lutris.logging
Class StandardLogger

java.lang.Object
  extended by com.lutris.logging.Logger
      extended by com.lutris.logging.StandardLogger

public class StandardLogger
extends com.lutris.logging.Logger

Standard implementation of the Logger. This is general-purpose logging facility. A client that needs additional functionality can either extend this class or provide there own implementationm of Logger.

Currently this is a bare-bones class that writes INFO and above levels to stderr and all others to a log file.

Author:
Mark Diekhans
See Also:
Logger, LogChannel, StandardLogChannel

Field Summary
protected  boolean[] enabledLevelFlags
          Table of levels that are to be enabled.
protected  java.lang.String[] levelNames
          Table translating level number to name and the largest entry in the array that is valid.
protected  boolean[] logFileLevelFlags
          Table of levels that are to be written to the log file.
protected  int numLevels
           
protected  boolean[] stderrLevelFlags
          Table of levels that are to be written to stderr Accessed directly by the channel.
 
Fields inherited from class com.lutris.logging.Logger
ALERT, centralLogger, CRITICAL, DEBUG, DEBUG1, DEBUG2, DEBUG3, DEBUG4, DEBUG5, DEBUG6, DEBUG7, DEBUG8, DEBUG9, DEBUGTMP, EMERGENCY, ERROR, INFO, MAX_STD_LEVEL, NOTICE, standardLevelNames, WARNING
 
Constructor Summary
StandardLogger(boolean makeCentral)
          Construct a new logger.
 
Method Summary
 void configure(com.lutris.util.Config logConfig)
          Configure Logger with given config section
 void configure(java.io.File logFile, java.lang.String[] fileLevels, java.lang.String[] stderrLevels)
          Configure the logger.
 void configure(java.lang.String confFilePath)
          Configure Logger with given config file, interpreting of config file is logger implementation specific.
 com.lutris.logging.LogChannel getChannel(java.lang.String facility)
          Get the log channel object for a facility.
 int getLevel(java.lang.String level)
          Convert a symbolic level to an integer identifier, creating it if it doesn't exist
 java.lang.String getLevelName(int level)
          Convert an int to a symbolic level name.
 java.io.File switchLogFile(java.io.File logFile)
          Switch a log file; replacing the old one with a new one.
 
Methods inherited from class com.lutris.logging.Logger
getCentralLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

levelNames

protected java.lang.String[] levelNames
Table translating level number to name and the largest entry in the array that is valid. Will be expanded if needed.


numLevels

protected int numLevels

enabledLevelFlags

protected boolean[] enabledLevelFlags
Table of levels that are to be enabled. Accessed directly by the channel. If null, ignored.


logFileLevelFlags

protected boolean[] logFileLevelFlags
Table of levels that are to be written to the log file. Accessed directly by the channel. If null, ignored.


stderrLevelFlags

protected boolean[] stderrLevelFlags
Table of levels that are to be written to stderr Accessed directly by the channel. If null, then the default behavior of writing serious standard levels to stderr is in affect.

Constructor Detail

StandardLogger

public StandardLogger(boolean makeCentral)
Construct a new logger. Configuration is not done now, to allow the logger to be created very early.

Parameters:
makeCentral - Make this object the central logging object.
Method Detail

switchLogFile

public java.io.File switchLogFile(java.io.File logFile)
                           throws java.io.IOException
Switch a log file; replacing the old one with a new one.

Parameters:
logFile - The new log file.
Returns:
The File object for the previous log file, or null if there wasn't one.
Throws:
java.io.IOException - If an error occurs opening the log file.

configure

public void configure(java.io.File logFile,
                      java.lang.String[] fileLevels,
                      java.lang.String[] stderrLevels)
               throws java.io.IOException
Configure the logger. All current configuration is discarded. This is a simplistic initial implementation that just allows directing to a single log file or stderr on a level basis. A more complete interface will be provided in the future.

Parameters:
logFile - The log file to write to.
fileLevels - List of levels that will be written to the file.
stderrLevels - List of levels that will be written to stderr. The same level may appear in both lists.
Throws:
java.io.IOException - If an error occurs opening the log file.

getChannel

public com.lutris.logging.LogChannel getChannel(java.lang.String facility)
Get the log channel object for a facility. For a given facility, the same object is always returned.

Specified by:
getChannel in class com.lutris.logging.Logger
Parameters:
facility - Facility the channel is associated with.

getLevel

public int getLevel(java.lang.String level)
Convert a symbolic level to an integer identifier, creating it if it doesn't exist

Parameters:
level - Symbolic level that is to be checked.
Returns:
The numeric level identifier

getLevelName

public java.lang.String getLevelName(int level)
Convert an int to a symbolic level name.

Parameters:
level - an int level.
Returns:
The String symolic level name or null if there is not one.

configure

public void configure(java.lang.String confFilePath)
               throws com.lutris.util.ConfigException
Configure Logger with given config file, interpreting of config file is logger implementation specific.

Specified by:
configure in class com.lutris.logging.Logger
Parameters:
confFilePath - Path to configuration file.
Throws:
com.lutris.util.ConfigException

configure

public void configure(com.lutris.util.Config logConfig)
               throws com.lutris.util.ConfigException
Configure Logger with given config section

Specified by:
configure in class com.lutris.logging.Logger
Parameters:
logConfig - containing parameters for configuring logger
Throws:
com.lutris.util.ConfigException

EAF 7.6 Implementation