Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.core

public Class DebugContext

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .HashMap, .List, .Map, .StringTokenizer, .UUID, java.util.logging.Level, .Logger, org.glassfish.tyrus.spi.UpgradeResponse

A java.util.logging.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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
DebugContext.TracingThreshold

Tracing threshold - used for configuration granularity of information that will be sent in tracing headers.

public static enum
DebugContext.TracingType

Type of tracing - used for tracing configuration.

public static enum
DebugContext.Type

Type of the record - used to graphically distinguish these message types in the log.

Field Summary

Modifier and TypeField and Description
private List<DebugContext.LogRecord>
private String
private final long
private Map<String, List<String>>
private final Level

Constructor Summary

AccessConstructor and Description
public
DebugContext(DebugContext.TracingThreshold
tracing threshold.
tracingThreshold
)

Constructor that configures tracing to be ON and accepts tracing threshold as a parameter.

public
DebugContext()

Constructor that configures tracing to be OFF.

Method Summary

Modifier and TypeMethod and Description
public void
appendLogMessage(Logger
logger to be used to log the message.
logger
,
Level
message level.
loggingLevel
,
DebugContext.Type
type of the message.
type
,
Object...
message parts that will be concatenated to create a log message.
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.

public void
appendLogMessageWithThrowable(Logger
logger to be used to log the message.
logger
,
Level
message level.
loggingLevel
,
DebugContext.Type
type of the message.
type
,
Throwable
throwable that has been thrown.
t
,
Object...
message parts that will be stringified and concatenated to create a log message.
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.

public void
appendStandardOutputMessage(DebugContext.Type
type of the message.
type
,
String
message to be logged.
message
)

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.

public void
appendTraceMessage(Logger
logger to be used to log the message.
logger
,
Level
message level.
loggingLevel
,
DebugContext.Type
type of the message.
type
,
Object...
message parts that will be stringified and concatenated to create a log message.
messageParts
)

Append a message to the log and to the list of trace messages that are sent in handshake response.

public void
appendTraceMessageWithThrowable(Logger
logger to be used to log the message.
logger
,
Level
message level.
loggingLevel
,
DebugContext.Type
type of the message.
type
,
Throwable
throwable that has been thrown.
t
,
Object...
message parts that will be stringified and concatenated to create a log message.
messageParts
)

Append a message to the log and to the list of trace messages that are sent in handshake response.

private void
public void
flush()

Write pending messages to the log.

private String
formatLogMessage(String message, DebugContext.Type type, long timestamp)

public Map<String, List<String>>

Returns:

tracing headers.
getTracingHeaders
()

Get headers containing tracing messages.

public void
setSessionId(String
session ID.
sessionId
)

Set a session ID that will be used as a common identifier for logged messages related to the same upgrade request.

private String
stringifyMessageParts(Object... messageParts)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

logRecordsback to summary
private List<DebugContext.LogRecord> logRecords
sessionIdback to summary
private String sessionId
startTimestampback to summary
private final long startTimestamp
tracingHeadersback to summary
private Map<String, List<String>> tracingHeaders
tracingLevelback to summary
private final Level tracingLevel

Constructor Detail

DebugContextback to summary
public DebugContext(DebugContext.TracingThreshold tracingThreshold)

Constructor that configures tracing to be ON and accepts tracing threshold as a parameter.

Parameters
tracingThreshold:DebugContext.TracingThreshold

tracing threshold.

DebugContextback to summary
public DebugContext()

Constructor that configures tracing to be OFF.

Method Detail

appendLogMessageback to summary
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

logger to be used to log the message.

loggingLevel:Level

message level.

type:DebugContext.Type

type of the message.

messageParts:Object[]

message parts that will be concatenated to create a log message.

appendLogMessageWithThrowableback to summary
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

logger to be used to log the message.

loggingLevel:Level

message level.

type:DebugContext.Type

type of the message.

t:Throwable

throwable that has been thrown.

messageParts:Object[]

message parts that will be stringified and concatenated to create a log message.

appendStandardOutputMessageback to summary
public void appendStandardOutputMessage(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. Randomly generated session ID is used if a session has not been created.

Parameters
type:DebugContext.Type

type of the message.

message:String

message to be logged.

appendTraceMessageback to summary
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

logger to be used to log the message.

loggingLevel:Level

message level.

type:DebugContext.Type

type of the message.

messageParts:Object[]

message parts that will be stringified and concatenated to create a log message.

appendTraceMessageWithThrowableback to summary
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

logger to be used to log the message.

loggingLevel:Level

message level.

type:DebugContext.Type

type of the message.

t:Throwable

throwable that has been thrown.

messageParts:Object[]

message parts that will be stringified and concatenated to create a log message.

appendTracingHeaderback to summary
private void appendTracingHeader(String message)
flushback to summary
public void flush()

Write pending messages to the log.

formatLogMessageback to summary
private String formatLogMessage(String message, DebugContext.Type type, long timestamp)
getTracingHeadersback to summary
public Map<String, List<String>> getTracingHeaders()

Get headers containing tracing messages.

Returns:Map<String, List<String>>

tracing headers.

setSessionIdback to summary
public void setSessionId(String sessionId)

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:String

session ID.

stringifyMessagePartsback to summary
private String stringifyMessageParts(Object... messageParts)
org.glassfish.tyrus.core back to summary

private Class DebugContext.LogRecord

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Logger
logger

Logger that will be used to log the message.

private Level
loggingLevel

Logger level that will be used when logging the message.

private String
message

Message to be logged.

private boolean
printToSout

true if the record should be printed into standard output - used if a message should be "logged" even though the logging has been turned off or the configured logging level is too high.

private Throwable
t

Throwable to be logged.

private long
timestamp

Time when a the logged even has occurred.

private DebugContext.Type
type

Type of the record - used for graphical purposes when logging.

Constructor Summary

AccessConstructor and Description
pack-priv
LogRecord(Logger logger, Level loggingLevel, DebugContext.Type Type, String message, Throwable t, boolean printToSout)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private Logger logger

Logger that will be used to log the message.

loggingLevelback to summary
private Level loggingLevel

Logger level that will be used when logging the message.

messageback to summary
private String message

Message to be logged.

printToSoutback to summary
private boolean printToSout

true if the record should be printed into standard output - used if a message should be "logged" even though the logging has been turned off or the configured logging level is too high.

tback to summary
private Throwable t

Throwable to be logged.

timestampback to summary
private long timestamp

Time when a the logged even has occurred.

typeback to summary
private DebugContext.Type type

Type of the record - used for graphical purposes when logging.

Constructor Detail

LogRecordback to summary
pack-priv LogRecord(Logger logger, Level loggingLevel, DebugContext.Type Type, String message, Throwable t, boolean printToSout)
org.glassfish.tyrus.core back to summary

public final Enum DebugContext.TracingThreshold

extends Enum<DebugContext.TracingThreshold>
Class Inheritance

Tracing threshold - used for configuration granularity of information that will be sent in tracing headers.

Field Summary

Modifier and TypeField and Description
public static final DebugContext.TracingThreshold
SUMMARY

A less verbose tracing, an equivalent to java.util.logging.Level#FINER logging level.

public static final DebugContext.TracingThreshold
TRACE

A more verbose tracing, an equivalent to java.util.logging.Level#FINE logging level.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DebugContext.TracingThreshold
public static DebugContext.TracingThreshold[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

SUMMARYback to summary
public static final DebugContext.TracingThreshold SUMMARY

A less verbose tracing, an equivalent to java.util.logging.Level#FINER logging level.

TRACEback to summary
public static final DebugContext.TracingThreshold TRACE

A more verbose tracing, an equivalent to java.util.logging.Level#FINE logging level.

The default tracing threshold.

Constructor Detail

TracingThresholdback to summary
private TracingThreshold()

Method Detail

valueOfback to summary
public static DebugContext.TracingThreshold valueOf(String name)
valuesback to summary
public static DebugContext.TracingThreshold[] values()
org.glassfish.tyrus.core back to summary

public final Enum DebugContext.TracingType

extends Enum<DebugContext.TracingType>
Class Inheritance

Type of tracing - used for tracing configuration.

Field Summary

Modifier and TypeField and Description
public static final DebugContext.TracingType
ALL

Tracing headers will be present in all handshake responses.

public static final DebugContext.TracingType
OFF

No tracing headers will be ever sent in handshake response.

public static final DebugContext.TracingType
ON_DEMAND

Tracing headers will be sent in handshake response only if X-Tyrus-Tracing-Accept header is present in handshake request.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DebugContext.TracingType
public static DebugContext.TracingType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLback to summary
public static final DebugContext.TracingType ALL

Tracing headers will be present in all handshake responses.

OFFback to summary
public static final DebugContext.TracingType OFF

No tracing headers will be ever sent in handshake response.

ON_DEMANDback to summary
public static final DebugContext.TracingType ON_DEMAND

Tracing headers will be sent in handshake response only if X-Tyrus-Tracing-Accept header is present in handshake request.

Constructor Detail

TracingTypeback to summary
private TracingType()

Method Detail

valueOfback to summary
public static DebugContext.TracingType valueOf(String name)
valuesback to summary
public static DebugContext.TracingType[] values()
org.glassfish.tyrus.core back to summary

public final Enum DebugContext.Type

extends Enum<DebugContext.Type>
Class Inheritance

Type of the record - used to graphically distinguish these message types in the log.

Field Summary

Modifier and TypeField and Description
public static final DebugContext.Type
public static final DebugContext.Type
public static final DebugContext.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static DebugContext.Type
public static DebugContext.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

MESSAGE_INback to summary
public static final DebugContext.Type MESSAGE_IN
MESSAGE_OUTback to summary
public static final DebugContext.Type MESSAGE_OUT
OTHERback to summary
public static final DebugContext.Type OTHER

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static DebugContext.Type valueOf(String name)
valuesback to summary
public static DebugContext.Type[] values()