private static final class TracingLogger.TracingLoggerImpl extends TracingLogger
TracingLogger.Event, TracingLogger.Level
Modifier and Type | Field and Description |
---|---|
private java.util.logging.Logger |
logger |
private TracingLogger.Level |
threshold |
private TracingInfo |
tracingInfo |
DEFAULT_LEVEL, HEADER_ACCEPT, HEADER_LOGGER, HEADER_THRESHOLD, PROPERTY_NAME
Constructor and Description |
---|
TracingLoggerImpl(TracingLogger.Level threshold,
java.lang.String loggerNameSuffix) |
Modifier and Type | Method and Description |
---|---|
void |
flush(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> headers)
Stores collected tracing messages to response HTTP header.
|
private static java.lang.String |
formatInstance(java.lang.Object instance)
Format info of instance.
|
private static void |
formatInstance(java.lang.Object instance,
java.lang.StringBuilder textSB)
Basic format of instance - just class name and identity hash code.
|
private static void |
formatResponse(javax.ws.rs.core.Response response,
java.lang.StringBuilder textSB)
Format of response - status code, status family, reason phrase and info about entity.
|
private static java.lang.String |
formatStatusInfo(javax.ws.rs.core.Response.StatusType statusInfo) |
private boolean |
isEnabled(TracingLogger.Level level) |
boolean |
isLogEnabled(TracingLogger.Event event)
Test if a tracing support is enabled (according to
propertiesDelegate setting) and
if event can be logged (according to event.level and threshold level set). |
void |
log(TracingLogger.Event event,
java.lang.Object... args)
Try to log event according to event level and request context threshold level setting.
|
void |
logDuration(TracingLogger.Event event,
long fromTimestamp,
java.lang.Object... args)
Try to log event according to event level and request context threshold level setting.
|
private void |
logImpl(TracingLogger.Event event,
long duration,
java.lang.Object... messageArgs)
Log message for specified event type.
|
long |
timestamp(TracingLogger.Event event)
If logging support is switched on for current request and event setting the method returns current timestamp in nanos.
|
create, empty, getInstance
private final java.util.logging.Logger logger
private final TracingLogger.Level threshold
private final TracingInfo tracingInfo
public TracingLoggerImpl(TracingLogger.Level threshold, java.lang.String loggerNameSuffix)
public boolean isLogEnabled(TracingLogger.Event event)
TracingLogger
propertiesDelegate
setting) and
if event
can be logged (according to event.level
and threshold level set).isLogEnabled
in class TracingLogger
event
- event type to be testedtrue
if event
can be loggedpublic void log(TracingLogger.Event event, java.lang.Object... args)
TracingLogger
log
in class TracingLogger
event
- event type to be loggedargs
- message arguments (in relation to .Event#messageFormat()
public void logDuration(TracingLogger.Event event, long fromTimestamp, java.lang.Object... args)
TracingLogger
fromTimestamp
is not set (i.e. -1
) then duration of event
is 0
.logDuration
in class TracingLogger
event
- event type to be loggedfromTimestamp
- logged event is running from the timestamp in nanos. -1
in case event has no durationargs
- message arguments (in relation to .Event#messageFormat()
public long timestamp(TracingLogger.Event event)
TracingLogger
timestamp
in class TracingLogger
event
- event type to be logged-1
if tracing is not enabledpublic void flush(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> headers)
TracingLogger
flush
in class TracingLogger
headers
- message headers.private void logImpl(TracingLogger.Event event, long duration, java.lang.Object... messageArgs)
messageArgs
is used to format event.
If there is no message format then each message arg is separated by space.
Final message also contains event name (JDK Log) or category (HTTP header) and time stamp.event
- Event type of logduration
- Time duration of logged event. Can be 0
.messageArgs
- message argumentsprivate boolean isEnabled(TracingLogger.Level level)
private static java.lang.String formatInstance(java.lang.Object instance)
instance
- instance to be formattedprivate static void formatInstance(java.lang.Object instance, java.lang.StringBuilder textSB)
instance
- instance to be formattedtextSB
- Formatted info will be appended to StringBuilder
private static void formatResponse(javax.ws.rs.core.Response response, java.lang.StringBuilder textSB)
response
- response to be formattedtextSB
- Formatted info will be appended to StringBuilder
private static java.lang.String formatStatusInfo(javax.ws.rs.core.Response.StatusType statusInfo)