public class DebugLogger extends WrappingLogger
Since not all logging methods have all context information themselves (for
instance the session token is not provided to each internal method), the
context information will be registered per thread. Logging without this
information will just use the last provided context information.
The context information will be set when
registering a
session as active. Since sessions are hierarchical and one session resp. its
subsessions may be registered several times. Therefore a stack is used for
the log record parameters. When
unregistering the
subsession, the last element will be popped from the stack.
Additionally a log context can be changed, that is some parameters can be changed intermediately. These changes can be undone completely and the original log context will be restored.
Besides the context information the logger also allows to adapt the source
class and method name. This can be used for logging when (un-)registering the
current session as start and finish logs but not logging the superclass but
the calling class and method. Setting the source class and name only applies
to the next call to log by the same thread.
Note that this logger is just a tiny wrapper to a normal logger and thus
completely outside the logger hierarchy. It does not have any parent or child
loggers.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.ThreadLocal<java.util.Stack<Pair<java.lang.Object[],java.lang.Object[]>>> |
logRecordParameters
The parameter stacks depending on the current thread.
|
protected java.lang.ThreadLocal<Pair<java.lang.String,java.lang.String>> |
recordSource
The source class name (first element) and the source method name for the
next log-call of the current thread.
|
protected java.lang.String |
serviceInstName
The name of the service for which to log.
|
protected java.lang.String |
serviceIntName
The name of the service interface for which to log.
|
innerLogger| Constructor and Description |
|---|
DebugLogger(java.lang.Class<?> serviceInterface,
java.lang.String serviceInstance,
java.util.logging.Logger innerLogger)
Creates a new logger for adding several AristaFlow-specific parameters and
the nanoseconds to log records.
|
DebugLogger(java.lang.String serviceInterface,
java.lang.String serviceInstance,
java.util.logging.Logger innerLogger)
Creates a new logger for adding several AristaFlow-specific parameters and
the nanoseconds to log records.
|
| Modifier and Type | Method and Description |
|---|---|
void |
adaptNextSource(int stackElement)
Sets the source class name and the source method for the next log record of
the current thread.
|
void |
changeLogContext(SessionToken session,
QualifiedAgent tlAgent,
QualifiedAgent agent,
java.lang.String arbString,
java.util.UUID templID,
java.util.UUID baseTemplID,
java.util.UUID embdTemplID,
java.util.UUID instID,
EBPInstanceReference ebpIR)
Changes the current log record parameter values intermediately for the
designated session to the designated values.
|
void |
log(java.util.logging.LogRecord record)
Logs the designated record by the wrapped logger in case the wrapped logger
logs the corresponding level.
|
void |
registerLogContext(SessionToken session,
QualifiedAgent tlAgent,
QualifiedAgent agent,
java.lang.String arbString,
java.util.UUID templID,
java.util.UUID baseTemplID,
java.util.UUID embdTemplID,
java.util.UUID instID,
EBPInstanceReference ebpIR)
Registers a new (sub-)session with the designated log record parameters.
|
void |
revertLogContextChanges()
Reverts the current changes of the log context registered for the current
thread.
|
protected void |
setLogParameters(java.lang.Object[] logParameters,
SessionToken session,
QualifiedAgent tlAgent,
QualifiedAgent agent,
java.lang.String arbString,
java.util.UUID templID,
java.util.UUID baseTemplID,
java.util.UUID embdTemplID,
java.util.UUID instID,
EBPInstanceReference ebpIR)
Sets the designated values as parameters for log records.
|
void |
unregisterLogContext()
Unregisters the session and the corresponding log context of the current
thread from this logger, that is all log record parameters of the current
subsession will be dropped from the parameter stack per (top-level)
session.
|
addHandler, equals, getFilter, getHandlers, getLevel, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, hashCode, isLoggable, removeHandler, setFilter, setLevel, setLevel, setParent, setUseParentHandlersconfig, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getGlobal, getLogger, getLogger, info, info, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, setResourceBundle, severe, severe, throwing, warning, warningprotected final java.lang.ThreadLocal<java.util.Stack<Pair<java.lang.Object[],java.lang.Object[]>>> logRecordParameters
protected final java.lang.ThreadLocal<Pair<java.lang.String,java.lang.String>> recordSource
protected final java.lang.String serviceInstName
protected final java.lang.String serviceIntName
public DebugLogger(java.lang.Class<?> serviceInterface,
java.lang.String serviceInstance,
java.util.logging.Logger innerLogger)
log(LogRecord)) will just be forwarded to the designated wrapped
logger.serviceInterface - The interface of the main service of this logger.
This may be null.serviceInstance - The hierarchical name of the service instance. This
may be null.innerLogger - The logger to which all requests will be forwarded.public DebugLogger(java.lang.String serviceInterface,
java.lang.String serviceInstance,
java.util.logging.Logger innerLogger)
log(LogRecord)) will just be forwarded to the designated wrapped
logger.serviceInterface - The name of the interface of the main service of
this logger. This may be null.serviceInstance - The hierarchical name of the service instance. This
may be null.innerLogger - The logger to which all requests will be forwarded.public void log(java.util.logging.LogRecord record)
System.nanoTime() and AristaFlow-specific parameters (if
available) to the log record. Additionally, the source class name and the
source method name will be adapted. If they have been
set explicitly both will be unset afterwards.log in class WrappingLoggerpublic void adaptNextSource(int stackElement)
stackElement - The index of the stack element to use for the source
class name and source method. 0 indicates the top of the stack,
that is the most recent method which is always this method.public void registerLogContext(SessionToken session, QualifiedAgent tlAgent, QualifiedAgent agent, java.lang.String arbString, java.util.UUID templID, java.util.UUID baseTemplID, java.util.UUID embdTemplID, java.util.UUID instID, EBPInstanceReference ebpIR)
session - The session for which to create new log record parameters.
This may be null.tlAgent - The agent of the top-level session token for the log record.
This may be null.agent - The agent of the session token for the log record. This may be
null.arbString - An arbitrary additional string for the log record allowing
to sort and/or filter the log. This may be null.templID - The template ID for the log record. This may be null.baseTemplID - The base template ID for the log record. This may be
null.embdTemplID - The (internal) ID of the embedded template ID the for
the log record. This may be null.instID - The instance ID for the log record. This may be null.ebpIR - The EBPInstanceReference for the log record. This
may be null.InternalServiceException - If the designated session has not been
registered yet, an InternalServiceException will be
thrown.public void changeLogContext(SessionToken session, QualifiedAgent tlAgent, QualifiedAgent agent, java.lang.String arbString, java.util.UUID templID, java.util.UUID baseTemplID, java.util.UUID embdTemplID, java.util.UUID instID, EBPInstanceReference ebpIR)
arbString - An arbitrary additional string for the log record allowing
to sort and/or filter the log. This may be null.session - The session for the log record. This may be null.tlAgent - The agent of the top-level session token for the log record.
This may be null.agent - The agent of the session token for the log record. This may be
null.templID - The template ID for the log record. This may be null.baseTemplID - The base template ID for the log record. This may be
null.embdTemplID - The (internal) ID of the embedded template ID the for
the log record. This may be null.instID - The instance ID for the log record. This may be null.ebpIR - The EBPInstanceReference for the log record. This
may be null.InternalServiceException - If the designated session (or no log
context for the current thread) has not been registered yet, an
InternalServiceException will be thrown.public void revertLogContextChanges()
InternalServiceException - If no log context for the current thread
has not been registered yet, an
InternalServiceException will be thrown.public void unregisterLogContext()
protected void setLogParameters(java.lang.Object[] logParameters,
SessionToken session,
QualifiedAgent tlAgent,
QualifiedAgent agent,
java.lang.String arbString,
java.util.UUID templID,
java.util.UUID baseTemplID,
java.util.UUID embdTemplID,
java.util.UUID instID,
EBPInstanceReference ebpIR)
logParameters - The array in which to set the designated values. This
must not be null.session - The session for the log record. This may be null.tlAgent - The agent of the top-level session token for the log record.
This may be null.agent - The agent of the session token for the log record. This may be
null.arbString - An arbitrary additional string for the log record allowing
to sort and/or filter the log. This may be null.templID - The template ID for the log record. This may be null.baseTemplID - The base template ID for the log record. This may be
null.embdTemplID - The (internal) ID of the embedded template ID the for
the log record. This may be null.instID - The instance ID for the log record. This may be null.ebpIR - The EBPInstanceReference for the log record. This
may be null.