T
- The actual tracer typepublic abstract class DebugLogTee<T extends AbstractTracer> extends AbstractTracer
AbstractTracer
base class but does so by wrapping and delegating to another AbstractTracer
.
Besides two abstract adapt methods must be implemented to route log messages to the desired log system. Note that the wrapped tracer instance must
not be a NullTracer
. An adapter which is only interested in logging messages and wants to discard the additional tracing information altogether
should be derived directly from the NullTracer
.AbstractTracer.Exception
Modifier and Type | Field and Description |
---|---|
protected T |
tracer
Some tracer.
|
VERSION
Constructor and Description |
---|
DebugLogTee(String name,
T tracer)
Constructor expects the name of the tracer and the to be wrapped Tracer instance.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
adapt(LogLevel logLevel,
String message,
Class clazz)
Derived classes should provide code which routes the given message with the denoted logLevel and class to the desired log system.
|
protected abstract void |
adapt(LogLevel logLevel,
Throwable throwable,
Class clazz)
Derived classes should provide code which routes the given throwable with the denoted logLevel and class to the desired log system.
|
void |
close()
Derived classes should provide code that closes the output streams.
|
TraceMethod |
entry(String methodSignature)
Deprecated.
|
TraceMethod |
entry(String returnType,
Class clazz,
String methodSignature)
Indicates an entering of a method which belongs to a class.
|
TraceMethod |
entry(String returnType,
Object object,
String methodSignature)
Indicates an entering of a method which belongs to an object.
|
int |
getBufferSize()
Gives the buffer size of the actual
TracePrintStream . |
String |
getName()
The name of the tracer.
|
Object |
getSyncObject()
Synchronizes access to the
TracePrintStream . |
void |
initCurrentTracingContext()
Initialises the current tracing context by taking the values for debugLevel and online from the configured
debug map.
|
void |
initCurrentTracingContext(int debugLevel,
boolean online)
Initialises the current tracing context with the given debugLevel and online state.
|
boolean |
isAutoflush()
Indicates whether the output stream will be flushed when leaving a
method by
AbstractTracer.wayout() . |
boolean |
isOpened()
Indicates whether the actual
TracePrintStream is opened. |
void |
logException(LogLevel logLevel,
Throwable throwable,
Class clazz,
String methodName)
Logs an exception with the given logLevel and the originating class.
|
void |
logMessage(LogLevel logLevel,
String message,
Class clazz,
String methodName)
Logs a message with the given logLevel and the originating class.
|
void |
open()
Derived classes should provide code that opens the respective output streams.
|
IndentablePrintStream |
out()
Returns some kind of an
IndentablePrintStream based upon the the current managed stack size, the configured debug
level and the online state of the current tracing context. |
protected void |
readConfiguration(XPath xpath,
Node node)
Reads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.
|
void |
setAutoflush(boolean autoflush)
Used during the configuration.
|
void |
setBufferSize(int bufferSize)
Configures the buffer size of the actual
TracePrintStream . |
TraceMethod |
wayout()
Indicates the exiting of a method.
|
clearCurrentTracingContext, formatStreamErrorState, formatVersionInfo, getBufferedOutputStream, getNullPrintStream, getThreadMap, getTracePrintStream, out, setBufferedOutputStream, setOpened, setTracePrintStream, substitute
protected final T extends AbstractTracer tracer
public final Object getSyncObject()
AbstractTracer
TracePrintStream
. Clients with multiple TracingContext
s should use it to synchronize their access to
AbstractTracer.out()
.getSyncObject
in class AbstractTracer
public final int getBufferSize()
AbstractTracer
TracePrintStream
.getBufferSize
in class AbstractTracer
public final boolean isAutoflush()
AbstractTracer
AbstractTracer.wayout()
.isAutoflush
in class AbstractTracer
public final boolean isOpened()
AbstractTracer
TracePrintStream
is opened.isOpened
in class AbstractTracer
public final String getName()
AbstractTracer
getName
in class AbstractTracer
public final void setBufferSize(int bufferSize)
AbstractTracer
TracePrintStream
.setBufferSize
in class AbstractTracer
bufferSize
- the bufferSize to setpublic final void setAutoflush(boolean autoflush)
AbstractTracer
AbstractTracer.wayout()
.setAutoflush
in class AbstractTracer
autoflush
- the autoflush to setprotected final void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception
AbstractTracer
readConfiguration
in class AbstractTracer
xpath
- the xpath enginenode
- the config nodeXPathExpressionException
- indicates xpath problemsAbstractTracer.Exception
- indicates problems when configuring certain tracer instancespublic void open()
AbstractTracer
open
in class AbstractTracer
public void close()
AbstractTracer
close
in class AbstractTracer
public final void initCurrentTracingContext()
AbstractTracer
initCurrentTracingContext
in class AbstractTracer
public final void initCurrentTracingContext(int debugLevel, boolean online)
AbstractTracer
initCurrentTracingContext
in class AbstractTracer
debugLevel
- controls the extent of the outputonline
- a value of false delivers no output of the current thread at all whereas a value of true delivers output controlled by debugLevelprotected abstract void adapt(LogLevel logLevel, String message, Class clazz)
logLevel
- the to be translated LogLevelmessage
- the actual messageclazz
- the class context of the messageprotected abstract void adapt(LogLevel logLevel, Throwable throwable, Class clazz)
logLevel
- the to be translated LogLevelthrowable
- references the to be logged infoclazz
- the class context of the messagepublic TraceMethod entry(String returnType, Class clazz, String methodSignature)
AbstractTracer
TracingContext
exists for the current thread a TraceMethod
object
will be created and thereupon pushed onto the stack of a ThreadMap
.entry
in class AbstractTracer
returnType
- the return type of the method as string representationclazz
- the class to which that method belongmethodSignature
- the remaining method signature (without return type) inclusive parameter as string representationpublic TraceMethod entry(String returnType, Object object, String methodSignature)
AbstractTracer
TracingContext
exists for the current thread a TraceMethod
object
will be created and thereupon pushed onto the stack of a ThreadMap
.entry
in class AbstractTracer
returnType
- the return type of the method as string representationobject
- the object that owns the methodmethodSignature
- the remaining method signature (without return type) inclusive parameter as string representation@Deprecated public TraceMethod entry(String methodSignature)
AbstractTracer
entry
in class AbstractTracer
methodSignature
- the signature of the method as string representationpublic final void logMessage(LogLevel logLevel, String message, Class clazz, String methodName)
AbstractTracer
logMessage
in class AbstractTracer
logLevel
- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREmessage
- the to be logged messageclazz
- the originating classmethodName
- the originating methodpublic final void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName)
AbstractTracer
logException
in class AbstractTracer
logLevel
- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREthrowable
- the to be logged throwableclazz
- the originating classpublic TraceMethod wayout()
AbstractTracer
wayout
in class AbstractTracer
public final IndentablePrintStream out()
AbstractTracer
IndentablePrintStream
based upon the the current managed stack size, the configured debug
level and the online state of the current tracing context. This is the NullPrintStream
if the stack size is greater
than the debug level or if the thread is offline. Otherwise it's the TracePrintStream
.out
in class AbstractTracer
IndentablePrintStream
Copyright © 2014 Christof Reichardt. All rights reserved. (Build: 26-May-2014)