Package org.jboss.netty.handler.logging
Class LoggingHandler
java.lang.Object
org.jboss.netty.handler.logging.LoggingHandler
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
,ChannelUpstreamHandler
@Sharable
public class LoggingHandler
extends Object
implements ChannelUpstreamHandler, ChannelDownstreamHandler
A
ChannelHandler
that logs all events via InternalLogger
.
By default, all events are logged at DEBUG level. You can extend
this class and override log(ChannelEvent)
to change the default
behavior.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]
private static final String[]
private static final String[]
private static final InternalLogLevel
private final boolean
private static final String[]
private final InternalLogLevel
private final InternalLogger
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.LoggingHandler
(boolean hexDump) Creates a new instance whose logger name is the fully qualified class name of the instance.LoggingHandler
(Class<?> clazz) Creates a new instance with the specified logger name and with hex dump enabled.LoggingHandler
(Class<?> clazz, boolean hexDump) Creates a new instance with the specified logger name.LoggingHandler
(Class<?> clazz, InternalLogLevel level) Creates a new instance with the specified logger name.LoggingHandler
(Class<?> clazz, InternalLogLevel level, boolean hexDump) Creates a new instance with the specified logger name.LoggingHandler
(String name) Creates a new instance with the specified logger name and with hex dump enabled.LoggingHandler
(String name, boolean hexDump) Creates a new instance with the specified logger name.LoggingHandler
(String name, InternalLogLevel level, boolean hexDump) Creates a new instance with the specified logger name.LoggingHandler
(InternalLogLevel level) Creates a new instance whose logger name is the fully qualified class name of the instance.LoggingHandler
(InternalLogLevel level, boolean hexDump) Creates a new instance whose logger name is the fully qualified class name of the instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
getLevel()
Returns theInternalLogLevel
that this handler uses to log aChannelEvent
.Returns theInternalLogger
that this handler uses to log aChannelEvent
.void
Handles the specified downstream event.void
Handles the specified upstream event.void
log
(ChannelEvent e) Logs the specified event to theInternalLogger
returned bygetLogger()
.
-
Field Details
-
DEFAULT_LEVEL
-
NEWLINE
-
BYTE2HEX
-
HEXPADDING
-
BYTEPADDING
-
BYTE2CHAR
private static final char[] BYTE2CHAR -
logger
-
level
-
hexDump
private final boolean hexDump
-
-
Constructor Details
-
LoggingHandler
public LoggingHandler()Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled. -
LoggingHandler
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log level
-
LoggingHandler
public LoggingHandler(boolean hexDump) Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
Creates a new instance with the specified logger name and with hex dump enabled. -
LoggingHandler
Creates a new instance with the specified logger name.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
Creates a new instance with the specified logger name.- Parameters:
level
- the log level
-
LoggingHandler
Creates a new instance with the specified logger name.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
Creates a new instance with the specified logger name and with hex dump enabled. -
LoggingHandler
Creates a new instance with the specified logger name.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
Creates a new instance with the specified logger name.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
-
Method Details
-
getLogger
Returns theInternalLogger
that this handler uses to log aChannelEvent
. -
getLevel
Returns theInternalLogLevel
that this handler uses to log aChannelEvent
. -
log
Logs the specified event to theInternalLogger
returned bygetLogger()
. If hex dump has been enabled for this handler, the hex dump of theChannelBuffer
in aMessageEvent
will be logged together. -
formatBuffer
-
handleUpstream
Description copied from interface:ChannelUpstreamHandler
Handles the specified upstream event.- Specified by:
handleUpstream
in interfaceChannelUpstreamHandler
- Parameters:
ctx
- the context object for this handlere
- the upstream event to process or intercept- Throws:
Exception
-
handleDownstream
Description copied from interface:ChannelDownstreamHandler
Handles the specified downstream event.- Specified by:
handleDownstream
in interfaceChannelDownstreamHandler
- Parameters:
ctx
- the context object for this handlere
- the downstream event to process or intercept- Throws:
Exception
-