public class LogManager extends Object implements Flushable
| Modifier and Type | Field and Description |
|---|---|
static char | CLASSCLASS. |
static String | CONFIG_LOCATION_DEFAULTDefault logger config file name |
static String | CONFIG_LOCATION_PROPProperty name for the logger config file location |
static char | DATEThese define the characters in the format line of the config file |
static int | DEFAULT_CONSOLEBUFFERSIZEDefault number of entries in the console buffer |
static String | DEFAULT_DATEFORMATDEFAULT_DATEFORMAT. |
static String | DEFAULT_DEFAULTLEVELDefault log level string |
static boolean | DEFAULT_DISPLAYONSCREENDefault setting for on-screen log display |
static String | DEFAULT_FILENAMEDefault log file name pattern |
static String | DEFAULT_FILESIZEDefault log file size limit as a string |
static String | DEFAULT_FORMATDefault log record format string |
static String | DEFAULT_ONSCREENLEVELDefault on-screen log level string |
static String | DEFAULT_ROTATIONLIMITDefault log rotation limit |
static String | FILENAME_OVERRIDE_PROPProperty name to override the log filename |
static char | MESSAGEMESSAGE. |
static char | PRIORITYPRIORITY. |
static String | PROP_CONSOLEBUFFERSIZEProperty name for the console buffer size |
static String | PROP_DATEFORMATProperty name for the date format pattern |
static String | PROP_DEFAULTLEVELProperty name for the default log level |
static String | PROP_DISPLAYONSCREENProperty name to enable or disable on-screen display |
static String | PROP_DISPLAYONSCREENLEVELProperty name for the minimum log level displayed on screen |
static String | PROP_FILENAMEProperty name for the log file name pattern |
static String | PROP_FILESIZEProperty name for the log file size limit |
static String | PROP_FORMATProperty name for the log record format string |
static String | PROP_RECORD_PREFIXPrefix for per-logger level override properties |
static String | PROP_ROTATIONLIMITProperty name for the log rotation limit |
static char | THREADTHREAD. |
| 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()Whether log messages should be printed to stdout. |
void | flush()Flush any pending records to disk. |
String | getBaseLogfilename() |
LogConsoleBuffer | getBuffer()Return the circular buffer holding recent log records for console display. |
int | getConsoleBufferSize()Maximum number of entries held in the console buffer. |
(package private) I2PAppContext | getContext()Convenience method for LogRecordFormatter |
SimpleDateFormat | getDateFormat()Any usage of returned formatter must be synchronized! |
String | getDateFormatPattern() |
String | getDefaultLimit() |
int | getDisplayOnScreenLevel()Minimum log level for messages printed to stdout. |
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()Return all currently cached Log instances. |
(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 LogWriter thread to reload the config file. |
boolean | saveConfig()Save the current logging configuration to disk. |
void | setBaseLogfilename(String filenamePattern) |
void | setConfig(String filename)Set the logger config file path and reload configuration. |
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()Whether duplicate log records should be dropped. |
boolean | shouldGzip()Check if gzip compression should be used for rotated log files. |
void | shutdown()Shut down the log manager, flushing and stopping the writer. |
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)
context - the I2P app contextvoid addLog(Log log)
log - the Log to add and trackvoid addRecord(LogRecord record)
record - the log record to enqueuepublic 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()
public final Log getLog(Class<?> cls)
cls - the class to get the log forpublic final Log getLog(Class<?> cls, String name)
cls - the class (may be null)name - the namepublic List<Log> getLogs()
long getMinGzipSize()
public int getRotationLimit()
void rereadConfig()
public boolean saveConfig()
public void setBaseLogfilename(String filenamePattern)
filenamePattern - the base log filename patternpublic final void setConfig(String filename)
filename - the config file pathpublic 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)
lim - the default log limit stringpublic void setFileSize(int numBytes)
public void setFormat(char[] fmt)
fmt - the log format characterspublic 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()