java.lang.Object
net.i2p.util.LogWriter
net.i2p.util.FileLogWriter
- All Implemented Interfaces:
Runnable
File-based log writer thread that pulls log records from the LogManager, writes them to the current logfile, and rotates the logs as necessary.
Field Summary
Fields inherited from class LogWriter
_manager, _write, FLUSH_INTERVALModifier and TypeFieldDescriptionprotected final LogManagerThe log manager owning this writer and its context.protected booleanWhether the writer should continue writing.(package private) static final longAjax refresh interval.Constructor Summary
ConstructorsConstructorDescriptionFileLogWriter(LogManager manager) Creates a writer that drains log records to rotating files on disk.Method Summary
Modifier and TypeMethodDescriptionprotected voidClose the log file writer.File may not exist or have old logs in it if not opened yet.protected voidFlush the log file writer.(package private) static booleanisGroupTraversable(File dir) Whether the group can traverse (search) an existing directory.protected voidwriteRecord(int priority, String val) Write the formatted record text at the given priority.protected voidwriteRecord(LogRecord rec, String formatted) Write the record and its formatted text, using the record's priority.Methods inherited from class LogWriter
flushRecords, flushRecords, run, setFlushInterval, stopWriting, wakeupModifier and TypeMethodDescriptionvoidFlush pending log records.voidflushRecords(boolean shouldWait) Flush pending log records, optionally waiting for new ones.voidrun()Write loop, flushing records and rereading config until stopped.voidsetFlushInterval(long interval) Flush interval for the log writer, clamped to the supported range.voidStop the log writer thread.voidwakeup()Wake up the writer to immediately re-read config and flush pending records.
Constructor Details
FileLogWriter
Creates a writer that drains log records to rotating files on disk.- Parameters:
manager- the LogManager this writer drains records from; its configuration supplies the log directory and rotation settings
Method Details
currentFile
File may not exist or have old logs in it if not opened yet.- Specified by:
currentFilein classLogWriter- Returns:
- non-null
isGroupTraversable
Whether the group can traverse (search) an existing directory. Group execute on the directory is what allows a group-readable file inside it to be opened, so this is the check that decides whether group-readable log files are actually reachable.- Parameters:
dir- the directory to test- Returns:
- true if the group has execute/search permission, or if permissions cannot be determined
writeRecord
Write the record and its formatted text, using the record's priority.- Specified by:
writeRecordin classLogWriter- Parameters:
rec- the LogRecord to write.formatted- a String pre-formatted from rec, may be ignored.
writeRecord
Write the formatted record text at the given priority.- Specified by:
writeRecordin classLogWriter- Parameters:
priority- the level to log the line at.val- the String to write.
flushWriter
closeWriter