Package org.glassfish.tyrus.core
Class DebugContext
java.lang.Object
org.glassfish.tyrus.core.DebugContext
A
Logger wrapper that gives logging records a common formatting and temporarily stores log
records and postpones their logging until they can be provided with a session ID. After a session ID has been
provided, messages are logged immediately.
Log records are provided with a session ID, so that log records from a single upgrade request can be easily linked together in a log of a busy server or client.
- Author:
- Petr Janouch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTracing threshold - used for configuration granularity of information that will be sent in tracing headers.static enumType of tracing - used for tracing configuration.static enumType of the record - used to graphically distinguish these message types in the log. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that configures tracing to be OFF.DebugContext(DebugContext.TracingThreshold tracingThreshold) Constructor that configures tracing to be ON and accepts tracing threshold as a parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendLogMessage(Logger logger, Level loggingLevel, DebugContext.Type type, Object... messageParts) Append a message to the log, the logging will be postponed until the message can be provided with a session ID.voidappendLogMessageWithThrowable(Logger logger, Level loggingLevel, DebugContext.Type type, Throwable t, Object... messageParts) Append a message to the log, the logging will be postponed until the message can be provided with a session ID.voidappendStandardOutputMessage(DebugContext.Type type, String message) Write a message to the standard output, the logging will be postponed until the message can be provided with a session ID.voidappendTraceMessage(Logger logger, Level loggingLevel, DebugContext.Type type, Object... messageParts) Append a message to the log and to the list of trace messages that are sent in handshake response.voidappendTraceMessageWithThrowable(Logger logger, Level loggingLevel, DebugContext.Type type, Throwable t, Object... messageParts) Append a message to the log and to the list of trace messages that are sent in handshake response.voidflush()Write pending messages to the log.Get headers containing tracing messages.voidsetSessionId(String sessionId) Set a session ID that will be used as a common identifier for logged messages related to the same upgrade request.
-
Constructor Details
-
DebugContext
Constructor that configures tracing to be ON and accepts tracing threshold as a parameter.- Parameters:
tracingThreshold- tracing threshold.
-
DebugContext
public DebugContext()Constructor that configures tracing to be OFF.
-
-
Method Details
-
appendLogMessage
public void appendLogMessage(Logger logger, Level loggingLevel, DebugContext.Type type, Object... messageParts) Append a message to the log, the logging will be postponed until the message can be provided with a session ID. Randomly generated session ID is used if a session has not been created.- Parameters:
logger- logger to be used to log the message.loggingLevel- message level.type- type of the message.messageParts- message parts that will be concatenated to create a log message.
-
appendTraceMessage
public void appendTraceMessage(Logger logger, Level loggingLevel, DebugContext.Type type, Object... messageParts) Append a message to the log and to the list of trace messages that are sent in handshake response. The logging will be postponed until the message can be provided with a session ID. Randomly generated session ID is used if a session has not been created.- Parameters:
logger- logger to be used to log the message.loggingLevel- message level.type- type of the message.messageParts- message parts that will be stringified and concatenated to create a log message.
-
appendLogMessageWithThrowable
public void appendLogMessageWithThrowable(Logger logger, Level loggingLevel, DebugContext.Type type, Throwable t, Object... messageParts) Append a message to the log, the logging will be postponed until the message can be provided with a session ID. Randomly generated session ID is used if a session has not been created.- Parameters:
logger- logger to be used to log the message.loggingLevel- message level.type- type of the message.t- throwable that has been thrown.messageParts- message parts that will be stringified and concatenated to create a log message.
-
appendTraceMessageWithThrowable
public void appendTraceMessageWithThrowable(Logger logger, Level loggingLevel, DebugContext.Type type, Throwable t, Object... messageParts) Append a message to the log and to the list of trace messages that are sent in handshake response. The logging will be postponed until the message can be provided with a session ID. Randomly generated session ID is used if a session has not been created.- Parameters:
logger- logger to be used to log the message.loggingLevel- message level.type- type of the message.t- throwable that has been thrown.messageParts- message parts that will be stringified and concatenated to create a log message.
-
appendStandardOutputMessage
Write a message to the standard output, the logging will be postponed until the message can be provided with a session ID. Randomly generated session ID is used if a session has not been created.- Parameters:
type- type of the message.message- message to be logged.
-
setSessionId
Set a session ID that will be used as a common identifier for logged messages related to the same upgrade request. Setting the session ID will cause the pending messages to be written into the log.- Parameters:
sessionId- session ID.
-
flush
public void flush()Write pending messages to the log. -
getTracingHeaders
Get headers containing tracing messages.- Returns:
- tracing headers.
-