Class TracingLogger.TracingLoggerImpl
- java.lang.Object
-
- org.glassfish.jersey.message.internal.TracingLogger
-
- org.glassfish.jersey.message.internal.TracingLogger.TracingLoggerImpl
-
- Enclosing class:
- TracingLogger
private static final class TracingLogger.TracingLoggerImpl extends TracingLogger
Real implementation of tracing logger.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.glassfish.jersey.message.internal.TracingLogger
TracingLogger.Event, TracingLogger.Level
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.logging.Logger
logger
private TracingLogger.Level
threshold
private TracingInfo
tracingInfo
-
Fields inherited from class org.glassfish.jersey.message.internal.TracingLogger
DEFAULT_LEVEL, HEADER_ACCEPT, HEADER_LOGGER, HEADER_THRESHOLD, PROPERTY_NAME
-
-
Constructor Summary
Constructors Constructor Description TracingLoggerImpl(TracingLogger.Level threshold, java.lang.String loggerNameSuffix)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 topropertiesDelegate
setting) and ifevent
can be logged (according toevent.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.-
Methods inherited from class org.glassfish.jersey.message.internal.TracingLogger
create, empty, getInstance
-
-
-
-
Field Detail
-
logger
private final java.util.logging.Logger logger
-
threshold
private final TracingLogger.Level threshold
-
tracingInfo
private final TracingInfo tracingInfo
-
-
Constructor Detail
-
TracingLoggerImpl
public TracingLoggerImpl(TracingLogger.Level threshold, java.lang.String loggerNameSuffix)
-
-
Method Detail
-
isLogEnabled
public boolean isLogEnabled(TracingLogger.Event event)
Description copied from class:TracingLogger
Test if a tracing support is enabled (according topropertiesDelegate
setting) and ifevent
can be logged (according toevent.level
and threshold level set).- Specified by:
isLogEnabled
in classTracingLogger
- Parameters:
event
- event type to be tested- Returns:
true
ifevent
can be logged
-
log
public void log(TracingLogger.Event event, java.lang.Object... args)
Description copied from class:TracingLogger
Try to log event according to event level and request context threshold level setting.- Specified by:
log
in classTracingLogger
- Parameters:
event
- event type to be loggedargs
- message arguments (in relation to.Event#messageFormat()
-
logDuration
public void logDuration(TracingLogger.Event event, long fromTimestamp, java.lang.Object... args)
Description copied from class:TracingLogger
Try to log event according to event level and request context threshold level setting. If logging support is switched on for current request and event setting the method computes duration of event and log message. IffromTimestamp
is not set (i.e.-1
) then duration of event is0
.- Specified by:
logDuration
in classTracingLogger
- Parameters:
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()
-
timestamp
public long timestamp(TracingLogger.Event event)
Description copied from class:TracingLogger
If logging support is switched on for current request and event setting the method returns current timestamp in nanos.- Specified by:
timestamp
in classTracingLogger
- Parameters:
event
- event type to be logged- Returns:
- Current timestamp in nanos or
-1
if tracing is not enabled
-
flush
public void flush(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> headers)
Description copied from class:TracingLogger
Stores collected tracing messages to response HTTP header.- Specified by:
flush
in classTracingLogger
- Parameters:
headers
- message headers.
-
logImpl
private void logImpl(TracingLogger.Event event, long duration, java.lang.Object... messageArgs)
Log message for specified event type. The event contains name, category, level and also message format. Message format will be formatted by parametermessageArgs
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.- Parameters:
event
- Event type of logduration
- Time duration of logged event. Can be0
.messageArgs
- message arguments
-
isEnabled
private boolean isEnabled(TracingLogger.Level level)
-
formatInstance
private static java.lang.String formatInstance(java.lang.Object instance)
Format info of instance. It shows its class name, identity hash code, and following info if available: priority value, response detail.- Parameters:
instance
- instance to be formatted- Returns:
- Formatted info of instance.
-
formatInstance
private static void formatInstance(java.lang.Object instance, java.lang.StringBuilder textSB)
Basic format of instance - just class name and identity hash code.- Parameters:
instance
- instance to be formattedtextSB
- Formatted info will be appended toStringBuilder
-
formatResponse
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.- Parameters:
response
- response to be formattedtextSB
- Formatted info will be appended toStringBuilder
-
formatStatusInfo
private static java.lang.String formatStatusInfo(javax.ws.rs.core.Response.StatusType statusInfo)
-
-