public class LogManager extends Object implements Flushable
| Modifier and Type | Field and Description |
|---|---|
static char |
CLASS
These define the characters in the format line of the config file
|
static String |
CONFIG_LOCATION_DEFAULT |
static String |
CONFIG_LOCATION_PROP |
static char |
DATE
These define the characters in the format line of the config file
|
static int |
DEFAULT_CONSOLEBUFFERSIZE |
static String |
DEFAULT_DATEFORMAT
blank means default short date and medium time for the locale - see DateFormat
|
static String |
DEFAULT_DEFAULTLEVEL |
static boolean |
DEFAULT_DISPLAYONSCREEN |
static String |
DEFAULT_FILENAME |
static String |
DEFAULT_FILESIZE |
static String |
DEFAULT_FORMAT |
static String |
DEFAULT_ONSCREENLEVEL |
static String |
DEFAULT_ROTATIONLIMIT |
static 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 String |
PROP_CONSOLEBUFFERSIZE |
static String |
PROP_DATEFORMAT |
static String |
PROP_DEFAULTLEVEL |
static String |
PROP_DISPLAYONSCREEN |
static String |
PROP_DISPLAYONSCREENLEVEL |
static String |
PROP_FILENAME |
static String |
PROP_FILESIZE |
static String |
PROP_FORMAT |
static String |
PROP_RECORD_PREFIX |
static String |
PROP_ROTATIONLIMIT |
static char |
THREAD
These define the characters in the format line of the config file
|
| Constructor and Description |
|---|
LogManager(I2PAppContext context) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addLog(Log log)
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 |
addRecord(LogRecord record)
Used by Log to add records to the queue.
|
String |
currentFile()
File may not exist or have old logs in it if not opened yet
|
boolean |
displayOnScreen() |
void |
flush()
Flush any pending records to disk.
|
String |
getBaseLogfilename() |
LogConsoleBuffer |
getBuffer() |
int |
getConsoleBufferSize() |
(package private) I2PAppContext |
getContext()
Convenience method for LogRecordFormatter
|
SimpleDateFormat |
getDateFormat()
Any usage of returned formatter must be synchronized!
|
String |
getDateFormatPattern() |
String |
getDefaultLimit() |
int |
getDisplayOnScreenLevel() |
int |
getFileSize() |
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[] |
getFormat() |
Properties |
getLimits()
Return a mapping of the explicit overrides - path prefix to (text
formatted) limit.
|
Log |
getLog(Class<?> cls) |
Log |
getLog(Class<?> cls,
String name) |
Log |
getLog(String name) |
List<Log> |
getLogs()
now used by ConfigLogingHelper
|
(package private) long |
getMinGzipSize()
Get the minimum size for gzip compression.
|
(package private) Queue<LogRecord> |
getQueue()
Zero-copy.
|
int |
getRotationLimit() |
(package private) void |
rereadConfig()
Called periodically by the log writer's thread
Do not log here, deadlock of LogWriter
|
boolean |
saveConfig()
Save the current logging configuration to disk.
|
void |
setBaseLogfilename(String filenamePattern) |
void |
setConfig(String filename) |
boolean |
setDateFormat(String format)
Update the date format
Do not log here, deadlock of LogWriter via rereadConfig().
|
void |
setDefaultLimit(String lim) |
void |
setFileSize(int numBytes)
Update the log file size limit
|
void |
setFormat(char[] fmt) |
void |
setGzip(boolean yes)
Enable or disable gzip compression for rotated log files.
|
void |
setLimits(Properties limits)
Update the existing limit overrides
|
(package private) boolean |
shouldDropDuplicates() |
boolean |
shouldGzip()
Check if gzip compression should be used for rotated log files.
|
void |
shutdown() |
public static final char CLASS
public static final String CONFIG_LOCATION_DEFAULT
public static final String CONFIG_LOCATION_PROP
public static final char DATE
public static final int DEFAULT_CONSOLEBUFFERSIZE
public static final String DEFAULT_DATEFORMAT
public static final String DEFAULT_DEFAULTLEVEL
public static final boolean DEFAULT_DISPLAYONSCREEN
public static final String DEFAULT_FILENAME
public static final String DEFAULT_FILESIZE
public static final String DEFAULT_FORMAT
public static final String DEFAULT_ONSCREENLEVEL
public static final String DEFAULT_ROTATIONLIMIT
public static final String FILENAME_OVERRIDE_PROP
public static final char MESSAGE
public static final char PRIORITY
public static final String PROP_CONSOLEBUFFERSIZE
public static final String PROP_DATEFORMAT
public static final String PROP_DEFAULTLEVEL
public static final String PROP_DISPLAYONSCREEN
public static final String PROP_DISPLAYONSCREENLEVEL
public static final String PROP_FILENAME
public static final String PROP_FILESIZE
public static final String PROP_FORMAT
public static final String PROP_RECORD_PREFIX
public static final String PROP_ROTATIONLIMIT
public static final char THREAD
public LogManager(I2PAppContext context)
void addLog(Log log)
void addRecord(LogRecord record)
public String currentFile()
public boolean displayOnScreen()
public void flush()
public String getBaseLogfilename()
public LogConsoleBuffer getBuffer()
public int getConsoleBufferSize()
I2PAppContext getContext()
public SimpleDateFormat getDateFormat()
public String getDateFormatPattern()
public String getDefaultLimit()
public int getDisplayOnScreenLevel()
public int getFileSize()
public static int getFileSize(String size)
public char[] getFormat()
public Properties getLimits()
long getMinGzipSize()
public int getRotationLimit()
void rereadConfig()
public boolean saveConfig()
public void setBaseLogfilename(String filenamePattern)
public void setConfig(String filename)
public boolean setDateFormat(String format)
format - null or empty string means use default format for the locale
(with a SHORT date and a MEDIUM time - see DateFormat)public void setDefaultLimit(String lim)
public void setFileSize(int numBytes)
public void setFormat(char[] fmt)
public void setGzip(boolean yes)
yes - true to enable gzip compressionpublic void setLimits(Properties limits)
limits - mapping of prefix to log level string (not the log #)boolean shouldDropDuplicates()
public boolean shouldGzip()
public void shutdown()