@ChannelHandler.Sharable
public class LoggingHandler
extends io.netty.channel.ChannelHandlerAdapter
ChannelHandler that logs all events using a logging framework.
By default, all events are logged at DEBUG level.| Modifier and Type | Field and Description |
|---|---|
protected io.netty.util.internal.logging.InternalLogLevel |
internalLevel |
protected io.netty.util.internal.logging.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(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(LogLevel level)
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.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
appendHexDump(StringBuilder dump,
io.netty.buffer.ByteBuf buf)
Appends the prettifies multi-line hexadecimal dump of the specified
ByteBuf to the specified
StringBuilder. |
void |
bind(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelRegistered(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelUnregistered(io.netty.channel.ChannelHandlerContext ctx) |
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
deregister(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
disconnect(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
void |
flush(io.netty.channel.ChannelHandlerContext ctx) |
protected String |
format(io.netty.channel.ChannelHandlerContext ctx,
String eventName)
Formats an event and returns the formatted message.
|
protected String |
format(io.netty.channel.ChannelHandlerContext ctx,
String eventName,
Object arg)
Formats an event and returns the formatted message.
|
protected String |
format(io.netty.channel.ChannelHandlerContext ctx,
String eventName,
Object firstArg,
Object secondArg)
Formats an event and returns the formatted message.
|
LogLevel |
level()
Returns the
LogLevel that this handler uses to log |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
protected final io.netty.util.internal.logging.InternalLogger logger
protected final io.netty.util.internal.logging.InternalLogLevel internalLevel
public LoggingHandler()
public LoggingHandler(LogLevel level)
level - the log levelpublic 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(String name)
name - the name of the class to use for the loggerpublic void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelRegistered in interface io.netty.channel.ChannelHandlerchannelRegistered in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void channelUnregistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelUnregistered in interface io.netty.channel.ChannelHandlerchannelUnregistered in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelHandlerchannelActive in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelHandlerchannelInactive in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered in interface io.netty.channel.ChannelHandleruserEventTriggered in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void bind(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
bind in interface io.netty.channel.ChannelHandlerbind in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
connect in interface io.netty.channel.ChannelHandlerconnect in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void disconnect(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
disconnect in interface io.netty.channel.ChannelHandlerdisconnect in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
close in interface io.netty.channel.ChannelHandlerclose in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void deregister(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
deregister in interface io.netty.channel.ChannelHandlerderegister in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelHandlerchannelRead in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelHandlerwrite in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void flush(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
flush in interface io.netty.channel.ChannelHandlerflush in class io.netty.channel.ChannelHandlerAdapterExceptionprotected String format(io.netty.channel.ChannelHandlerContext ctx, String eventName)
eventName - the name of the eventprotected String format(io.netty.channel.ChannelHandlerContext ctx, String eventName, Object arg)
eventName - the name of the eventarg - the argument of the eventprotected String format(io.netty.channel.ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise).eventName - the name of the eventfirstArg - the first argument of the eventsecondArg - the second argument of the eventprotected static void appendHexDump(StringBuilder dump, io.netty.buffer.ByteBuf buf)
ByteBuf to the specified
StringBuilder.Copyright © 2008–2015 The Netty Project. All rights reserved.