Package net.i2p.util
Class LogManager
java.lang.Object
net.i2p.util.LogManager
- All Implemented Interfaces:
Flushable
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.
As of 0.9.41, this class may be overridden via I2PAppContext.setLogManager()
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
These define the characters in the format line of the config filestatic final String
static final String
static final char
These define the characters in the format line of the config filestatic final int
static final String
blank means default short date and medium time for the locale - see DateFormatstatic final String
static final boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final char
These define the characters in the format line of the config filestatic final char
These define the characters in the format line of the config filestatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final char
These define the characters in the format line of the config file -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) void
If the log already exists, its priority is set here but cannot be changed later, as it becomes an "orphan" not tracked by the manager.(package private) void
Used by Log to add records to the queue.File may not exist or have old logs in it if not opened yetboolean
void
flush()
Flush any pending records to disk.int
(package private) I2PAppContext
Convenience method for LogRecordFormatterAny usage of returned formatter must be synchronized!int
int
static int
getFileSize
(String size) Determine how many bytes are in the given formatted string (5m, 60g, 100k, etc) Size may be k, m, or g; a trailing b is ignored.char[]
Return a mapping of the explicit overrides - path prefix to (text formatted) limit.getLogs()
now used by ConfigLogingHelper(package private) long
getQueue()
Zero-copy.int
(package private) void
Called periodically by the log writer's thread Do not log here, deadlock of LogWriterboolean
void
setBaseLogfilename
(String filenamePattern) void
void
setConsoleBufferSize
(int numRecords) Deprecated.unusedboolean
setDateFormat
(String format) Update the date format Do not log here, deadlock of LogWriter via rereadConfig().void
setDefaultLimit
(String lim) void
setDisplayOnScreen
(boolean yes) Deprecated.unusedvoid
setDisplayOnScreenLevel
(int level) Deprecated.unusedvoid
setFileSize
(int numBytes) Update the log file size limitvoid
setFormat
(char[] fmt) void
setGzip
(boolean yes) void
setLimits
(Properties limits) Update the existing limit overrides(package private) boolean
boolean
void
shutdown()
-
Field Details
-
CONFIG_LOCATION_PROP
- See Also:
-
FILENAME_OVERRIDE_PROP
- See Also:
-
CONFIG_LOCATION_DEFAULT
- See Also:
-
DATE
public static final char DATEThese define the characters in the format line of the config file- See Also:
-
CLASS
public static final char CLASSThese define the characters in the format line of the config file- See Also:
-
THREAD
public static final char THREADThese define the characters in the format line of the config file- See Also:
-
PRIORITY
public static final char PRIORITYThese define the characters in the format line of the config file- See Also:
-
MESSAGE
public static final char MESSAGEThese define the characters in the format line of the config file- See Also:
-
PROP_FORMAT
- See Also:
-
PROP_DATEFORMAT
- See Also:
-
PROP_FILENAME
- See Also:
-
PROP_FILESIZE
- See Also:
-
PROP_ROTATIONLIMIT
- See Also:
-
PROP_DISPLAYONSCREEN
- See Also:
-
PROP_CONSOLEBUFFERSIZE
- See Also:
-
PROP_DISPLAYONSCREENLEVEL
- See Also:
-
PROP_DEFAULTLEVEL
- See Also:
-
PROP_RECORD_PREFIX
- See Also:
-
DEFAULT_FORMAT
- See Also:
-
DEFAULT_DATEFORMAT
blank means default short date and medium time for the locale - see DateFormat- See Also:
-
DEFAULT_FILENAME
- See Also:
-
DEFAULT_FILESIZE
- See Also:
-
DEFAULT_DISPLAYONSCREEN
public static final boolean DEFAULT_DISPLAYONSCREEN- See Also:
-
DEFAULT_CONSOLEBUFFERSIZE
public static final int DEFAULT_CONSOLEBUFFERSIZE- See Also:
-
DEFAULT_ROTATIONLIMIT
- See Also:
-
DEFAULT_DEFAULTLEVEL
- See Also:
-
DEFAULT_ONSCREENLEVEL
- See Also:
-
-
Constructor Details
-
LogManager
-
-
Method Details
-
getLog
-
getLog
-
getLog
-
getLogs
now used by ConfigLogingHelper -
addLog
If the log already exists, its priority is set here but cannot be changed later, as it becomes an "orphan" not tracked by the manager. -
getBuffer
-
setDisplayOnScreen
Deprecated.unused -
displayOnScreen
public boolean displayOnScreen() -
getDisplayOnScreenLevel
public int getDisplayOnScreenLevel() -
setDisplayOnScreenLevel
Deprecated.unused -
getConsoleBufferSize
public int getConsoleBufferSize() -
setConsoleBufferSize
Deprecated.unused -
setConfig
-
currentFile
File may not exist or have old logs in it if not opened yet- Returns:
- non-null
-
addRecord
Used by Log to add records to the queue. This is generally nonblocking and unsyncrhonized but may block when under massive logging load as a way of throttling logging threads. -
rereadConfig
void rereadConfig()Called periodically by the log writer's thread Do not log here, deadlock of LogWriter -
shouldDropDuplicates
boolean shouldDropDuplicates()- Since:
- 0.9.3
-
setLimits
Update the existing limit overrides- Parameters:
limits
- mapping of prefix to log level string (not the log #)
-
setDateFormat
Update the date format Do not log here, deadlock of LogWriter via rereadConfig().- Parameters:
format
- null or empty string means use default format for the locale (with a SHORT date and a MEDIUM time - see DateFormat)- 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
-
setDefaultLimit
-
getLimits
Return a mapping of the explicit overrides - path prefix to (text formatted) limit. -
getFileSize
Determine how many bytes are in the given formatted string (5m, 60g, 100k, etc) Size may be k, m, or g; a trailing b is ignored. Upper-case is allowed. Spaces between the number and letter is are allowed. The number may be in floating point. 16K min, 2 GB max (returns int) -
getBaseLogfilename
-
setBaseLogfilename
-
getFileSize
public int getFileSize() -
getRotationLimit
public int getRotationLimit() -
shouldGzip
public boolean shouldGzip()- Since:
- 0.9.56, public since 0.9.57, was pkg private
-
setGzip
public void setGzip(boolean yes) - Since:
- 0.9.57
-
getMinGzipSize
long getMinGzipSize()- Since:
- 0.9.56
-
saveConfig
public boolean saveConfig()- Returns:
- success
-
getQueue
Zero-copy. For the LogWriter- Since:
- 0.8.2
-
getFormat
public char[] getFormat() -
setFormat
public void setFormat(char[] fmt) -
getDateFormat
Any usage of returned formatter must be synchronized! -
getDateFormatPattern
-
flush
public void flush()Flush any pending records to disk. Blocking up to 250 ms. -
shutdown
public void shutdown() -
getContext
I2PAppContext getContext()Convenience method for LogRecordFormatter- Since:
- 0.7.14
-