public class FileLoggerHook extends LoggerHook implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
static class |
FileLoggerHook.IntervalParseException |
LoggerHook.DetailedThreshold, LoggerHook.InvalidThresholdException
Logger.LogLevel, Logger.OSThread
Modifier and Type | Field and Description |
---|---|
protected java.io.OutputStream |
altLogStream
Other stream to write data to (may be null)
|
protected java.lang.String |
baseFilename |
static int |
CLASS
Verbosity types
|
static int |
DATE
Verbosity types
|
static int |
HASHCODE
Verbosity types
|
protected int |
INTERVAL |
protected int |
INTERVAL_MULTIPLIER |
protected java.io.File |
latestFile |
protected java.util.concurrent.ArrayBlockingQueue<byte[]> |
list
Something weird happens when the disk gets full, also we don't want to
block So run the actual write on another thread
Unfortunately, we can't use ConcurrentBlockingQueue because we need to dump stuff when the queue gets
too big.
|
protected long |
LIST_WRITE_THRESHOLD |
protected long |
listBytes |
protected java.util.Deque<freenet.support.FileLoggerHook.OldLogFile> |
logFiles |
protected boolean |
logOverwrite |
protected java.io.OutputStream |
logStream
Stream to write data to (compressed if rotate is on)
|
protected long |
MAX_LIST_BYTES |
protected int |
MAX_LIST_SIZE |
static int |
MESSAGE
Verbosity types
|
protected java.io.File |
previousFile |
static int |
PRIORITY
Verbosity types
|
protected boolean |
redirectStdErr |
protected boolean |
redirectStdOut |
protected int |
runningCompressors |
protected java.lang.Object |
runningCompressorsSync |
static int |
THREAD
Verbosity types
|
static int |
UNAME
Verbosity types
|
detailedThresholds, threshold
Constructor and Description |
---|
FileLoggerHook(boolean rotate,
java.lang.String baseFilename,
java.lang.String fmt,
java.lang.String dfmt,
java.lang.String logRotateInterval,
Logger.LogLevel threshold,
boolean assumeWorking,
boolean logOverwrite,
long maxOldLogfilesDiskUsage,
int maxListSize) |
FileLoggerHook(boolean rotate,
java.lang.String baseFilename,
java.lang.String fmt,
java.lang.String dfmt,
java.lang.String threshold,
java.lang.String logRotateInterval,
boolean assumeWorking,
boolean logOverwrite,
long maxOldLogFilesDiskUsage,
int maxListSize) |
FileLoggerHook(java.io.OutputStream os,
java.lang.String fmt,
java.lang.String dfmt,
Logger.LogLevel threshold) |
FileLoggerHook(java.io.OutputStream stream,
java.lang.String fmt,
java.lang.String dfmt,
Logger.LogLevel threshold,
boolean overwrite)
Create a Logger to send log output to the given PrintStream.
|
FileLoggerHook(java.io.OutputStream os,
java.lang.String fmt,
java.lang.String dfmt,
java.lang.String threshold) |
FileLoggerHook(java.lang.String filename,
java.lang.String fmt,
java.lang.String dfmt,
java.lang.String logRotateInterval,
Logger.LogLevel threshold,
boolean assumeWorking,
boolean logOverwrite,
long maxOldLogfilesDiskUsage,
int maxListSize)
Create a Logger to append to the given file.
|
FileLoggerHook(java.lang.String filename,
java.lang.String fmt,
java.lang.String dfmt,
java.lang.String threshold,
java.lang.String logRotateInterval,
boolean assumeWorking,
boolean logOverwrite,
long maxOldLogFilesDiskUsage,
int maxListSize) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
deleteAllOldLogFiles() |
void |
findOldLogFiles(java.util.GregorianCalendar gc)
Initialize oldLogFiles
|
protected java.lang.String |
getHourLogName(java.util.Calendar c,
int digit,
boolean compressed)
The extra parameter int digit is to be used for creating a logfile name
when a log exists already with the same date.
|
boolean |
hasRedirectedStdOutErrNoLock()
This is used by the lost-lock deadlock detector so MUST NOT TAKE A LOCK ever!
|
void |
listAvailableLogs(java.io.OutputStreamWriter writer)
Print a human- and script- readable list of available log files.
|
long |
listBytes() |
void |
log(java.lang.Object o,
java.lang.Class<?> c,
java.lang.String msg,
java.lang.Throwable e,
Logger.LogLevel priority)
Log a message
|
void |
logString(byte[] b) |
static int |
numberOf(char c) |
void |
sendLogByContainedDate(long time,
java.io.OutputStream os) |
void |
setInterval(java.lang.String intervalName) |
void |
setMaxBacklogNotBusy(long val) |
void |
setMaxListBytes(long len) |
void |
setMaxOldLogsSize(long val)
Set the maximum size of old (gzipped) log files to keep.
|
void |
start() |
void |
switchBaseFilename(java.lang.String filename) |
void |
trimOldLogFiles() |
void |
waitForSwitch() |
acceptPriority, getDetailedThresholds, getThresholdNew, instanceRegisterLogThresholdCallback, instanceShouldLog, instanceShouldLog, instanceUnregisterLogThresholdCallback, log, log, log, log, setDetailedThresholds, setThreshold, setThreshold
debug, debug, debug, debug, destroyChainIfEmpty, error, error, error, error, fatal, getChain, getThreshold, globalAddHook, globalGetThreshold, globalGetThresholdNew, globalRemoveHook, globalSetThreshold, globalSetThreshold, instanceShouldLog, instanceShouldLog, log, log, log, log, log, logStatic, logStatic, logStatic, minor, minor, minor, minor, normal, normal, normal, normal, registerClass, registerLogThresholdCallback, setThreshold, setupChain, setupStdoutLogging, setupStdoutLogging, shouldLog, shouldLog, shouldLog, shouldLog, unregisterLogThresholdCallback, warning, warning, warning, warning
public static final int DATE
public static final int CLASS
public static final int HASHCODE
public static final int THREAD
public static final int PRIORITY
public static final int MESSAGE
public static final int UNAME
protected int INTERVAL
protected int INTERVAL_MULTIPLIER
protected java.io.OutputStream logStream
protected java.io.OutputStream altLogStream
protected final boolean logOverwrite
protected java.lang.String baseFilename
protected java.io.File latestFile
protected java.io.File previousFile
protected boolean redirectStdOut
protected boolean redirectStdErr
protected final int MAX_LIST_SIZE
protected long MAX_LIST_BYTES
protected long LIST_WRITE_THRESHOLD
protected final java.util.concurrent.ArrayBlockingQueue<byte[]> list
protected long listBytes
protected final java.util.Deque<freenet.support.FileLoggerHook.OldLogFile> logFiles
protected int runningCompressors
protected java.lang.Object runningCompressorsSync
public FileLoggerHook(java.lang.String filename, java.lang.String fmt, java.lang.String dfmt, java.lang.String logRotateInterval, Logger.LogLevel threshold, boolean assumeWorking, boolean logOverwrite, long maxOldLogfilesDiskUsage, int maxListSize) throws java.io.IOException, FileLoggerHook.IntervalParseException
filename
- the name of the file to log to.fmt
- log message format stringdfmt
- date format stringthreshold
- Lowest logged priorityassumeWorking
- If false, check whether stderr and stdout are writable and if
not, redirect them to the log filejava.io.IOException
- if the file couldn't be opened for append.FileLoggerHook.IntervalParseException
public FileLoggerHook(java.lang.String filename, java.lang.String fmt, java.lang.String dfmt, java.lang.String threshold, java.lang.String logRotateInterval, boolean assumeWorking, boolean logOverwrite, long maxOldLogFilesDiskUsage, int maxListSize) throws java.io.IOException, LoggerHook.InvalidThresholdException, FileLoggerHook.IntervalParseException
java.io.IOException
LoggerHook.InvalidThresholdException
FileLoggerHook.IntervalParseException
public FileLoggerHook(java.io.OutputStream os, java.lang.String fmt, java.lang.String dfmt, Logger.LogLevel threshold) throws FileLoggerHook.IntervalParseException
public FileLoggerHook(java.io.OutputStream os, java.lang.String fmt, java.lang.String dfmt, java.lang.String threshold) throws LoggerHook.InvalidThresholdException, FileLoggerHook.IntervalParseException
public FileLoggerHook(java.io.OutputStream stream, java.lang.String fmt, java.lang.String dfmt, Logger.LogLevel threshold, boolean overwrite) throws FileLoggerHook.IntervalParseException
stream
- the PrintStream to send log output to.fmt
- log message format stringdfmt
- date format stringthreshold
- Lowest logged priorityFileLoggerHook.IntervalParseException
public FileLoggerHook(boolean rotate, java.lang.String baseFilename, java.lang.String fmt, java.lang.String dfmt, java.lang.String logRotateInterval, Logger.LogLevel threshold, boolean assumeWorking, boolean logOverwrite, long maxOldLogfilesDiskUsage, int maxListSize) throws java.io.IOException, FileLoggerHook.IntervalParseException
java.io.IOException
FileLoggerHook.IntervalParseException
public FileLoggerHook(boolean rotate, java.lang.String baseFilename, java.lang.String fmt, java.lang.String dfmt, java.lang.String threshold, java.lang.String logRotateInterval, boolean assumeWorking, boolean logOverwrite, long maxOldLogFilesDiskUsage, int maxListSize) throws java.io.IOException, LoggerHook.InvalidThresholdException, FileLoggerHook.IntervalParseException
java.io.IOException
LoggerHook.InvalidThresholdException
FileLoggerHook.IntervalParseException
public void setMaxListBytes(long len)
public void setInterval(java.lang.String intervalName) throws FileLoggerHook.IntervalParseException
protected java.lang.String getHourLogName(java.util.Calendar c, int digit, boolean compressed)
c
- digit
- log file name suffix. ignored if this is < 0
compressed
- public void trimOldLogFiles()
public void findOldLogFiles(java.util.GregorianCalendar gc)
public void start()
public void log(java.lang.Object o, java.lang.Class<?> c, java.lang.String msg, java.lang.Throwable e, Logger.LogLevel priority)
LoggerHook
log
in class LoggerHook
o
- The object where this message was generated.c
- The class where this message was generated.msg
- A clear and verbose message describing the evente
- Logs this exception with the message.priority
- The priority of the mesage, one of LogLevel.ERROR,
LogLevel.NORMAL, LogLevel.MINOR, or LogLevel.DEBUG.public void logString(byte[] b) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public long listBytes()
public static int numberOf(char c)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void listAvailableLogs(java.io.OutputStreamWriter writer) throws java.io.IOException
java.io.IOException
public void sendLogByContainedDate(long time, java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void setMaxOldLogsSize(long val)
public void switchBaseFilename(java.lang.String filename)
public void waitForSwitch()
public void deleteAllOldLogFiles()
public boolean hasRedirectedStdOutErrNoLock()
public void setMaxBacklogNotBusy(long val)