Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lutris.logging
Class StandardLogger  view StandardLogger download StandardLogger.java

java.lang.Object
  extended bycom.lutris.logging.Logger
      extended bycom.lutris.logging.StandardLogger

public class StandardLogger
extends 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.


Field Summary
(package private)  java.io.File activeLogFile
          Log file name.
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.
private  java.util.Hashtable levelNumbers
          Table of level names to level numbers.
private  java.util.Hashtable logChannels
          Table of StandardLogChannel objects, indexed by facility name.
protected  boolean[] logFileLevelFlags
          Table of levels that are to be written to the log file.
(package private)  java.io.PrintWriter logFileStream
          Log file writter.
protected  int numLevels
           
protected  boolean[] stderrLevelFlags
          Table of levels that are to be written to stderr Accessed directly by the channel.
(package private)  java.io.PrintWriter stderrStream
          Stderr writter.
 
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(java.io.File logFile, java.lang.String[] fileLevels, java.lang.String[] stderrLevels)
          Configure the logger.
private  StandardLogChannel createChannel(java.lang.String facility)
          Create a log channel.
private  java.lang.Integer createLevel(java.lang.String level)
          Create a log level.
 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.
private  boolean[] getLevelStateArray(java.lang.String[] levels, int maxLevelNum)
          Generate a boolean array for all of the listed levels, indicating if they are enabled.
private  int getMaxLevel(java.lang.String[] levels)
          Get maximum level number in a set of level names.
 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

levelNumbers

private java.util.Hashtable levelNumbers
Table of level names to level numbers. While level configuration is local to a facility, a global table is kept assigning numbers to each level name.


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.


activeLogFile

java.io.File activeLogFile
Log file name.


logFileStream

java.io.PrintWriter logFileStream
Log file writter. Use directly by channels.


stderrStream

java.io.PrintWriter stderrStream
Stderr writter. Use directly by channels.


logChannels

private java.util.Hashtable logChannels
Table of StandardLogChannel objects, indexed by facility name.

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.

Method Detail

getMaxLevel

private int getMaxLevel(java.lang.String[] levels)
Get maximum level number in a set of level names.


getLevelStateArray

private boolean[] getLevelStateArray(java.lang.String[] levels,
                                     int maxLevelNum)
Generate a boolean array for all of the listed levels, indicating if they are enabled.


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.


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.


createChannel

private StandardLogChannel createChannel(java.lang.String facility)
Create a log channel.


getChannel

public 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 Logger

createLevel

private java.lang.Integer createLevel(java.lang.String level)
Create a log level.


getLevel

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


getLevelName

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