java.lang.Object
net.i2p.util.LogWriter
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
FileLogWriter
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longTimestamp of the first record displayed.private longThe current interval between the flushes, in milliseconds.private LogRecordThe last record displayed.private longTimestamp of last config reread.protected final LogManagerThe log manager owning this writer and its context.protected booleanWhether the writer should continue writing.private static final booleanWhether the displayed buffer shows newest first, false for oldest first.private static final StringBundle of the common translated strings.private static final longEvery 10 seconds? Why? Just have the gui force a reread after a change??(package private) static final longAjax refresh interval.private static final longLongest interval between the flushes.private static final longShortest interval between the flushes.private static final StringBundle of the router translated strings.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprotected abstract voidClose the writer.abstract StringFile may not exist or have old logs in it if not opened yet.private StringdupMessage(int dupCount, LogRecord lastRecord, boolean reverse, boolean html) Return a msg with the date stamp of the last duplicate.voidFlush pending log records.voidflushRecords(boolean shouldWait) Flush pending log records, optionally waiting for new ones.protected abstract voidFlush the writer output.private StringChoose the singular or plural form for a translated count.private voidRe-reads the display settings from the config.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.private voidwriteDupMessage(int dupCount, LogRecord lastRecord) Write a msg with the date stamp of the last duplicate.protected abstract voidwriteRecord(int priority, String line) Write a single String verbatim to the writer.private voidwriteRecord(LogRecord rec) Writes one record to the log file.protected abstract voidwriteRecord(LogRecord rec, String formatted) Write the provided LogRecord to the writer.
Field Details
CONFIG_READ_INTERVAL
private static final long CONFIG_READ_INTERVALEvery 10 seconds? Why? Just have the gui force a reread after a change??- See Also:
FLUSH_INTERVAL
MIN_FLUSH_INTERVAL
private static final long MIN_FLUSH_INTERVALShortest interval between the flushes.- See Also:
MAX_FLUSH_INTERVAL
private static final long MAX_FLUSH_INTERVALLongest interval between the flushes.- See Also:
BUFFER_DISPLAYED_REVERSE
private static final boolean BUFFER_DISPLAYED_REVERSEWhether the displayed buffer shows newest first, false for oldest first.- See Also:
_lastReadConfig
private volatile long _lastReadConfigTimestamp of last config reread._manager
The log manager owning this writer and its context._write
protected volatile boolean _writeWhether the writer should continue writing._last
The last record displayed._firstTimestamp
private long _firstTimestampTimestamp of the first record displayed._flushInterval
private volatile long _flushIntervalThe current interval between the flushes, in milliseconds.BUNDLE_NAME
Bundle of the common translated strings.- See Also:
ROUTER_BUNDLE_NAME
Bundle of the router translated strings.- See Also:
Constructor Details
LogWriter
Method Details
currentFile
File may not exist or have old logs in it if not opened yet.- Returns:
- non-null
writeRecord
writeRecord
Write a single String verbatim to the writer.- Parameters:
priority- the level to log the line at.line- the String to write.
flushWriter
protected abstract void flushWriter()Flush the writer output.closeWriter
protected abstract void closeWriter()Close the writer.stopWriting
public void stopWriting()Stop the log writer thread.setFlushInterval
public void setFlushInterval(long interval) Flush interval for the log writer, clamped to the supported range.- Parameters:
interval- the interval in milliseconds
wakeup
public void wakeup()Wake up the writer to immediately re-read config and flush pending records.run
flushRecords
public void flushRecords()Flush pending log records.flushRecords
public void flushRecords(boolean shouldWait) Flush pending log records, optionally waiting for new ones.- Parameters:
shouldWait- whether to wait for new records
writeDupMessage
Write a msg with the date stamp of the last duplicate.- Parameters:
dupCount- how many identical messages were omittedlastRecord- the last of the omitted duplicates, supplying priority and date
dupMessage
Return a msg with the date stamp of the last duplicate.- Parameters:
dupCount- how many identical messages were omittedlastRecord- the last of the omitted duplicates, supplying the date stampreverse- true for the down arrows used in the reverse-display buffer, false for uphtml- true to use HTML arrow entities, ignored on Android- Returns:
- the formatted omission message, terminated with the log newline marker
ngettext
rereadConfig
private void rereadConfig()Re-reads the display settings from the config.writeRecord
Writes one record to the log file.- Parameters:
rec- the record to write