net.i2p.util
Class LogManager

java.lang.Object
  extended by net.i2p.util.LogManager

public class LogManager
extends java.lang.Object

Manages the logging system, loading (and reloading) the configuration file, coordinating the log limits, and storing the set of log records pending. This also fires off a LogWriter thread that pulls pending records off and writes them where appropriate.


Field Summary
static char CLASS
          These define the characters in the format line of the config file
static java.lang.String CONFIG_LOCATION_DEFAULT
           
static java.lang.String CONFIG_LOCATION_PROP
           
static char DATE
          These define the characters in the format line of the config file
static int DEFAULT_CONSOLEBUFFERSIZE
           
static java.lang.String DEFAULT_DATEFORMAT
           
static java.lang.String DEFAULT_DEFAULTLEVEL
           
static boolean DEFAULT_DISPLAYONSCREEN
           
static java.lang.String DEFAULT_FILENAME
           
static java.lang.String DEFAULT_FILESIZE
           
static java.lang.String DEFAULT_FORMAT
           
static java.lang.String DEFAULT_ONSCREENLEVEL
           
static java.lang.String DEFAULT_ROTATIONLIMIT
           
static java.lang.String FILENAME_OVERRIDE_PROP
           
static char MESSAGE
          These define the characters in the format line of the config file
static char PRIORITY
          These define the characters in the format line of the config file
static java.lang.String PROP_CONSOLEBUFFERSIZE
           
static java.lang.String PROP_DATEFORMAT
           
static java.lang.String PROP_DEFAULTLEVEL
           
static java.lang.String PROP_DISPLAYONSCREEN
           
static java.lang.String PROP_DISPLAYONSCREENLEVEL
           
static java.lang.String PROP_FILENAME
           
static java.lang.String PROP_FILESIZE
           
static java.lang.String PROP_FORMAT
           
static java.lang.String PROP_RECORD_PREFIX
           
static java.lang.String PROP_ROTATIONLIMIT
           
static char THREAD
          These define the characters in the format line of the config file
 
Constructor Summary
LogManager(I2PAppContext context)
           
 
Method Summary
(package private)  java.util.List<LogRecord> _removeAll()
           
(package private)  void addLog(Log log)
           
(package private)  void addRecord(LogRecord record)
          Used by Log to add records to the queue
 java.lang.String currentFile()
           
 boolean displayOnScreen()
           
 java.lang.String getBaseLogfilename()
           
 LogConsoleBuffer getBuffer()
           
 int getConsoleBufferSize()
           
(package private)  I2PAppContext getContext()
          Convenience method for LogRecordFormatter
 java.text.SimpleDateFormat getDateFormat()
           
 java.lang.String getDateFormatPattern()
           
 java.lang.String getDefaultLimit()
           
 int getDisplayOnScreenLevel()
           
 int getFileSize()
           
 int getFileSize(java.lang.String size)
          Determine how many bytes are in the given formatted string (5m, 60g, 100k, etc)
 char[] getFormat()
           
 java.util.Properties getLimits()
          Return a mapping of the explicit overrides - path prefix to (text formatted) limit.
 Log getLog(java.lang.Class cls)
           
 Log getLog(java.lang.Class cls, java.lang.String name)
           
 Log getLog(java.lang.String name)
           
 java.util.List<Log> getLogs()
          Deprecated. unused
 int getRotationLimit()
           
static void main(java.lang.String[] args)
           
(package private)  void rereadConfig()
          Called periodically by the log writer's thread
 boolean saveConfig()
           
 void setBaseLogfilename(java.lang.String filenamePattern)
           
 void setConfig(java.lang.String filename)
           
 void setConsoleBufferSize(int numRecords)
           
 boolean setDateFormat(java.lang.String format)
          Update the date format
 void setDefaultLimit(java.lang.String lim)
           
 void setDisplayOnScreen(boolean yes)
           
 void setDisplayOnScreenLevel(int level)
           
 void setFileSize(int numBytes)
          Update the log file size limit
 void setFormat(char[] fmt)
           
 void setLimits(java.util.Properties limits)
          Update the existing limit overrides
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_LOCATION_PROP

public static final java.lang.String CONFIG_LOCATION_PROP
See Also:
Constant Field Values

FILENAME_OVERRIDE_PROP

public static final java.lang.String FILENAME_OVERRIDE_PROP
See Also:
Constant Field Values

CONFIG_LOCATION_DEFAULT

public static final java.lang.String CONFIG_LOCATION_DEFAULT
See Also:
Constant Field Values

DATE

public static final char DATE
These define the characters in the format line of the config file

See Also:
Constant Field Values

CLASS

public static final char CLASS
These define the characters in the format line of the config file

See Also:
Constant Field Values

THREAD

public static final char THREAD
These define the characters in the format line of the config file

See Also:
Constant Field Values

PRIORITY

public static final char PRIORITY
These define the characters in the format line of the config file

See Also:
Constant Field Values

MESSAGE

public static final char MESSAGE
These define the characters in the format line of the config file

See Also:
Constant Field Values

PROP_FORMAT

public static final java.lang.String PROP_FORMAT
See Also:
Constant Field Values

PROP_DATEFORMAT

public static final java.lang.String PROP_DATEFORMAT
See Also:
Constant Field Values

PROP_FILENAME

public static final java.lang.String PROP_FILENAME
See Also:
Constant Field Values

PROP_FILESIZE

public static final java.lang.String PROP_FILESIZE
See Also:
Constant Field Values

PROP_ROTATIONLIMIT

public static final java.lang.String PROP_ROTATIONLIMIT
See Also:
Constant Field Values

PROP_DISPLAYONSCREEN

public static final java.lang.String PROP_DISPLAYONSCREEN
See Also:
Constant Field Values

PROP_CONSOLEBUFFERSIZE

public static final java.lang.String PROP_CONSOLEBUFFERSIZE
See Also:
Constant Field Values

PROP_DISPLAYONSCREENLEVEL

public static final java.lang.String PROP_DISPLAYONSCREENLEVEL
See Also:
Constant Field Values

PROP_DEFAULTLEVEL

public static final java.lang.String PROP_DEFAULTLEVEL
See Also:
Constant Field Values

PROP_RECORD_PREFIX

public static final java.lang.String PROP_RECORD_PREFIX
See Also:
Constant Field Values

DEFAULT_FORMAT

public static final java.lang.String DEFAULT_FORMAT
See Also:
Constant Field Values

DEFAULT_DATEFORMAT

public static final java.lang.String DEFAULT_DATEFORMAT
See Also:
Constant Field Values

DEFAULT_FILENAME

public static final java.lang.String DEFAULT_FILENAME
See Also:
Constant Field Values

DEFAULT_FILESIZE

public static final java.lang.String DEFAULT_FILESIZE
See Also:
Constant Field Values

DEFAULT_DISPLAYONSCREEN

public static final boolean DEFAULT_DISPLAYONSCREEN
See Also:
Constant Field Values

DEFAULT_CONSOLEBUFFERSIZE

public static final int DEFAULT_CONSOLEBUFFERSIZE
See Also:
Constant Field Values

DEFAULT_ROTATIONLIMIT

public static final java.lang.String DEFAULT_ROTATIONLIMIT
See Also:
Constant Field Values

DEFAULT_DEFAULTLEVEL

public static final java.lang.String DEFAULT_DEFAULTLEVEL
See Also:
Constant Field Values

DEFAULT_ONSCREENLEVEL

public static final java.lang.String DEFAULT_ONSCREENLEVEL
See Also:
Constant Field Values
Constructor Detail

LogManager

public LogManager(I2PAppContext context)
Method Detail

getLog

public Log getLog(java.lang.Class cls)

getLog

public Log getLog(java.lang.String name)

getLog

public Log getLog(java.lang.Class cls,
                  java.lang.String name)

getLogs

public java.util.List<Log> getLogs()
Deprecated. unused


addLog

void addLog(Log log)

getBuffer

public LogConsoleBuffer getBuffer()

setDisplayOnScreen

public void setDisplayOnScreen(boolean yes)

displayOnScreen

public boolean displayOnScreen()

getDisplayOnScreenLevel

public int getDisplayOnScreenLevel()

setDisplayOnScreenLevel

public void setDisplayOnScreenLevel(int level)

getConsoleBufferSize

public int getConsoleBufferSize()

setConsoleBufferSize

public void setConsoleBufferSize(int numRecords)

setConfig

public void setConfig(java.lang.String filename)

currentFile

public java.lang.String currentFile()

addRecord

void addRecord(LogRecord record)
Used by Log to add records to the queue


rereadConfig

void rereadConfig()
Called periodically by the log writer's thread


setLimits

public void setLimits(java.util.Properties limits)
Update the existing limit overrides

Parameters:
limits - mapping of prefix to log level string (not the log #)

setDateFormat

public boolean setDateFormat(java.lang.String format)
Update the date format

Returns:
true if the format was updated, false if it was invalid

setFileSize

public void setFileSize(int numBytes)
Update the log file size limit


getDefaultLimit

public java.lang.String getDefaultLimit()

setDefaultLimit

public void setDefaultLimit(java.lang.String lim)

getLimits

public java.util.Properties getLimits()
Return a mapping of the explicit overrides - path prefix to (text formatted) limit.


getFileSize

public int getFileSize(java.lang.String size)
Determine how many bytes are in the given formatted string (5m, 60g, 100k, etc)


getBaseLogfilename

public java.lang.String getBaseLogfilename()

setBaseLogfilename

public void setBaseLogfilename(java.lang.String filenamePattern)

getFileSize

public int getFileSize()

getRotationLimit

public int getRotationLimit()

saveConfig

public boolean saveConfig()

_removeAll

java.util.List<LogRecord> _removeAll()

getFormat

public char[] getFormat()

setFormat

public void setFormat(char[] fmt)

getDateFormat

public java.text.SimpleDateFormat getDateFormat()

getDateFormatPattern

public java.lang.String getDateFormatPattern()

main

public static void main(java.lang.String[] args)

shutdown

public void shutdown()

getContext

I2PAppContext getContext()
Convenience method for LogRecordFormatter

Since:
0.7.14