Class FileTracer
java.lang.Object
de.christofreichardt.diagnosis.AbstractTracer
de.christofreichardt.diagnosis.file.FileTracer
This particular tracer logs into the local file system.
- Author:
- Christof Reichardt
-
Nested Class Summary
Nested classes/interfaces inherited from class de.christofreichardt.diagnosis.AbstractTracer
AbstractTracer.Exception -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longindicates the lower bound of the number of bytes which leads to a log file rotationprotected intcounts the number of file splittingsprotected FileOutputStreamthe underlying OutputStreamprotected Pathdenotes default log directoryprotected Filethe actual log fileFields inherited from class de.christofreichardt.diagnosis.AbstractTracer
VERSION -
Constructor Summary
ConstructorsConstructorDescriptionFileTracer(String name) Constructor expects the preferably unique tracer name. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if the file size limit has been exceeded and splits the trace file if need be.voidclose()Closes the associated trace streams.longIndicates the lower bound of the number of bytes which leads to a log file rotation.Gives the path to the directory of the logfile.voidlogException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) Logs an exception with the given logLevel and the originating class.voidlogMessage(LogLevel logLevel, String message, Class clazz, String methodName) Logs a message with the given logLevel and the originating class.voidopen()Creates the underlying trace file and opens the associated trace streams.out()Returns some kind of anIndentablePrintStreambased upon the the current managed stack size, the configured debug level and the online state of the current tracing context.protected voidreadConfiguration(XPath xpath, Node node) Reads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.voidsetByteLimit(long byteLimit) Sets the lower bound of the number of bytes which leads to a log file rotation.voidsetLogDirPath(Path logDirPath) Sets the path to the directory of the logfile.Methods inherited from class de.christofreichardt.diagnosis.AbstractTracer
clearCurrentTracingContext, entry, entry, entry, formatStreamErrorState, formatVersionInfo, getBufferedOutputStream, getBufferSize, getName, getNullPrintStream, getSyncObject, getThreadMap, getTracePrintStream, initCurrentTracingContext, initCurrentTracingContext, isAutoflush, isOpened, out, setAutoflush, setBufferedOutputStream, setBufferSize, setOpened, setTracePrintStream, substitute, wayout
-
Field Details
-
traceLogfile
the actual log file -
fileOutputStream
the underlying OutputStream -
byteLimit
protected volatile long byteLimitindicates the lower bound of the number of bytes which leads to a log file rotation -
logDirPath
denotes default log directory -
counter
protected int countercounts the number of file splittings
-
-
Constructor Details
-
FileTracer
Constructor expects the preferably unique tracer name. This is at the same time the name of the logfile.- Parameters:
name- the name of the tracer
-
-
Method Details
-
getLogDirPath
Gives the path to the directory of the logfile.- Returns:
- the logDirPath
-
setLogDirPath
Sets the path to the directory of the logfile.- Parameters:
logDirPath- the logDirPath to set
-
getByteLimit
public long getByteLimit()Indicates the lower bound of the number of bytes which leads to a log file rotation.- Returns:
- the byteLimit
-
setByteLimit
public void setByteLimit(long byteLimit) Sets the lower bound of the number of bytes which leads to a log file rotation.- Parameters:
byteLimit- the byteLimit to set
-
open
public void open()Creates the underlying trace file and opens the associated trace streams. The file name will be assembled by the path to log directory and the name of the tracer.- Specified by:
openin classAbstractTracer
-
close
public void close()Closes the associated trace streams.- Specified by:
closein classAbstractTracer
-
readConfiguration
protected void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception Description copied from class:AbstractTracerReads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.- Overrides:
readConfigurationin classAbstractTracer- Parameters:
xpath- the xpath enginenode- the config node- Throws:
XPathExpressionException- indicates xpath problemsAbstractTracer.Exception- indicates problems when configuring certain tracer instances
-
checkLimit
protected void checkLimit()Checks if the file size limit has been exceeded and splits the trace file if need be. -
out
Description copied from class:AbstractTracerReturns some kind of anIndentablePrintStreambased upon the the current managed stack size, the configured debug level and the online state of the current tracing context. This is theNullPrintStreamif the stack size is greater than the debug level or if the thread is offline. Otherwise it's theTracePrintStream.- Overrides:
outin classAbstractTracer- Returns:
- an
IndentablePrintStream
-
logException
Description copied from class:AbstractTracerLogs an exception with the given logLevel and the originating class.- Overrides:
logExceptionin classAbstractTracer- Parameters:
logLevel- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREthrowable- the to be logged throwableclazz- the originating classmethodName- the name of the relevant method
-
logMessage
Description copied from class:AbstractTracerLogs a message with the given logLevel and the originating class.- Overrides:
logMessagein classAbstractTracer- Parameters:
logLevel- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREmessage- the to be logged messageclazz- the originating classmethodName- the originating method
-