@ChannelHandler.Sharable public class LoggingHandler extends ChannelDuplexHandler
ChannelHandler
that logs all events using a logging framework.
By default, all events are logged at DEBUG level and full hex dumps are recorded for ByteBufs.ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected InternalLogLevel |
internalLevel |
protected InternalLogger |
logger |
Constructor and Description |
---|
LoggingHandler()
Creates a new instance whose logger name is the fully qualified class
name of the instance with hex dump enabled.
|
LoggingHandler(ByteBufFormat format)
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,
LogLevel level)
Creates a new instance with the specified logger name.
|
LoggingHandler(Class<?> clazz,
LogLevel level,
ByteBufFormat byteBufFormat)
Creates a new instance with the specified logger name.
|
LoggingHandler(LogLevel level)
Creates a new instance whose logger name is the fully qualified class
name of the instance.
|
LoggingHandler(LogLevel level,
ByteBufFormat byteBufFormat)
Creates a new instance whose logger name is the fully qualified class
name of the instance.
|
LoggingHandler(String name)
Creates a new instance with the specified logger name using the default log level.
|
LoggingHandler(String name,
LogLevel level)
Creates a new instance with the specified logger name.
|
LoggingHandler(String name,
LogLevel level,
ByteBufFormat byteBufFormat)
Creates a new instance with the specified logger name.
|
read
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded, handlerRemoved
protected final InternalLogger logger
protected final InternalLogLevel internalLevel
public LoggingHandler()
public LoggingHandler(ByteBufFormat format)
format
- Format of ByteBuf dumpingpublic LoggingHandler(LogLevel level)
level
- the log levelpublic LoggingHandler(LogLevel level, ByteBufFormat byteBufFormat)
level
- the log levelbyteBufFormat
- the ByteBuf formatpublic LoggingHandler(Class<?> clazz)
clazz
- the class type to generate the logger forpublic LoggingHandler(Class<?> clazz, LogLevel level)
clazz
- the class type to generate the logger forlevel
- the log levelpublic LoggingHandler(Class<?> clazz, LogLevel level, ByteBufFormat byteBufFormat)
clazz
- the class type to generate the logger forlevel
- the log levelbyteBufFormat
- the ByteBuf formatpublic LoggingHandler(String name)
name
- the name of the class to use for the loggerpublic LoggingHandler(String name, LogLevel level)
name
- the name of the class to use for the loggerlevel
- the log levelpublic LoggingHandler(String name, LogLevel level, ByteBufFormat byteBufFormat)
name
- the name of the class to use for the loggerlevel
- the log levelbyteBufFormat
- the ByteBuf formatpublic ByteBufFormat byteBufFormat()
ByteBufFormat
that this handler uses to logpublic void channelRegistered(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRegistered()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRegistered
in interface ChannelInboundHandler
channelRegistered
in class ChannelInboundHandlerAdapter
Exception
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelUnregistered()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelUnregistered
in interface ChannelInboundHandler
channelUnregistered
in class ChannelInboundHandlerAdapter
Exception
public void channelActive(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelActive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelActive
in interface ChannelInboundHandler
channelActive
in class ChannelInboundHandlerAdapter
Exception
public void channelInactive(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelInactive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelInactive
in interface ChannelInboundHandler
channelInactive
in class ChannelInboundHandlerAdapter
Exception
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
in interface ChannelHandler
exceptionCaught
in interface ChannelInboundHandler
exceptionCaught
in class ChannelInboundHandlerAdapter
Exception
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireUserEventTriggered(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.userEventTriggered
in interface ChannelInboundHandler
userEventTriggered
in class ChannelInboundHandlerAdapter
Exception
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.bind(SocketAddress, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.bind
in interface ChannelOutboundHandler
bind
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the bind operation is madelocalAddress
- the SocketAddress
to which it should boundpromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.connect
in interface ChannelOutboundHandler
connect
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the connect operation is maderemoteAddress
- the SocketAddress
to which it should connectlocalAddress
- the SocketAddress
which is used as source on connectpromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.disconnect(ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.disconnect
in interface ChannelOutboundHandler
disconnect
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the disconnect operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.close(ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.close
in interface ChannelOutboundHandler
close
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.deregister(ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.deregister
in interface ChannelOutboundHandler
deregister
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void channelReadComplete(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelReadComplete()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelReadComplete
in interface ChannelInboundHandler
channelReadComplete
in class ChannelInboundHandlerAdapter
Exception
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
in interface ChannelInboundHandler
channelRead
in class ChannelInboundHandlerAdapter
Exception
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.write(Object, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.write
in interface ChannelOutboundHandler
write
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelWritabilityChanged()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelWritabilityChanged
in interface ChannelInboundHandler
channelWritabilityChanged
in class ChannelInboundHandlerAdapter
Exception
public void flush(ChannelHandlerContext ctx) throws Exception
ChannelDuplexHandler
ChannelHandlerContext.flush()
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.flush
in interface ChannelOutboundHandler
flush
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the flush operation is madeException
- thrown if an error occursprotected String format(ChannelHandlerContext ctx, String eventName)
eventName
- the name of the eventprotected String format(ChannelHandlerContext ctx, String eventName, Object arg)
eventName
- the name of the eventarg
- the argument of the eventprotected String format(ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
.eventName
- the name of the eventfirstArg
- the first argument of the eventsecondArg
- the second argument of the eventCopyright © 2008–2024 The Netty Project. All rights reserved.