Package io.netty5.handler.logging
Class LoggingHandler
- java.lang.Object
-
- io.netty5.handler.logging.LoggingHandler
-
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
@Sharable public class LoggingHandler extends Object implements io.netty5.channel.ChannelHandler
AChannelHandlerthat logs all events using a logging framework. By default, all events are logged at DEBUG level and full hex dumps are recorded for ByteBufs.
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty5.util.internal.logging.InternalLogLevelinternalLevelprotected io.netty5.util.internal.logging.InternalLoggerlogger
-
Constructor Summary
Constructors Constructor 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(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(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(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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.netty5.util.concurrent.Future<Void>bind(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress localAddress)ByteBufFormatbyteBufFormat()Returns theByteBufFormatthat this handler uses to logvoidchannelActive(io.netty5.channel.ChannelHandlerContext ctx)voidchannelInactive(io.netty5.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty5.channel.ChannelHandlerContext ctx, Object msg)voidchannelReadComplete(io.netty5.channel.ChannelHandlerContext ctx)voidchannelRegistered(io.netty5.channel.ChannelHandlerContext ctx)voidchannelUnregistered(io.netty5.channel.ChannelHandlerContext ctx)voidchannelWritabilityChanged(io.netty5.channel.ChannelHandlerContext ctx)io.netty5.util.concurrent.Future<Void>close(io.netty5.channel.ChannelHandlerContext ctx)io.netty5.util.concurrent.Future<Void>connect(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)io.netty5.util.concurrent.Future<Void>deregister(io.netty5.channel.ChannelHandlerContext ctx)io.netty5.util.concurrent.Future<Void>disconnect(io.netty5.channel.ChannelHandlerContext ctx)voidexceptionCaught(io.netty5.channel.ChannelHandlerContext ctx, Throwable cause)voidflush(io.netty5.channel.ChannelHandlerContext ctx)protected Stringformat(io.netty5.channel.ChannelHandlerContext ctx, String eventName)Formats an event and returns the formatted message.protected Stringformat(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object arg)Formats an event and returns the formatted message.protected Stringformat(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)Formats an event and returns the formatted message.LogLevellevel()Returns theLogLevelthat this handler uses to logvoiduserEventTriggered(io.netty5.channel.ChannelHandlerContext ctx, Object evt)io.netty5.util.concurrent.Future<Void>write(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
-
-
-
Constructor Detail
-
LoggingHandler
public LoggingHandler()
Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.
-
LoggingHandler
public LoggingHandler(ByteBufFormat format)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
format- Format of ByteBuf dumping
-
LoggingHandler
public LoggingHandler(LogLevel level)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level- the log level
-
LoggingHandler
public LoggingHandler(LogLevel level, ByteBufFormat byteBufFormat)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level- the log levelbyteBufFormat- the ByteBuf format
-
LoggingHandler
public LoggingHandler(Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump enabled.- Parameters:
clazz- the class type to generate the logger for
-
LoggingHandler
public LoggingHandler(Class<?> clazz, LogLevel level)
Creates a new instance with the specified logger name.- Parameters:
clazz- the class type to generate the logger forlevel- the log level
-
LoggingHandler
public LoggingHandler(Class<?> clazz, LogLevel level, ByteBufFormat byteBufFormat)
Creates a new instance with the specified logger name.- Parameters:
clazz- the class type to generate the logger forlevel- the log levelbyteBufFormat- the ByteBuf format
-
LoggingHandler
public LoggingHandler(String name)
Creates a new instance with the specified logger name using the default log level.- Parameters:
name- the name of the class to use for the logger
-
LoggingHandler
public LoggingHandler(String name, LogLevel level)
Creates a new instance with the specified logger name.- Parameters:
name- the name of the class to use for the loggerlevel- the log level
-
LoggingHandler
public LoggingHandler(String name, LogLevel level, ByteBufFormat byteBufFormat)
Creates a new instance with the specified logger name.- Parameters:
name- the name of the class to use for the loggerlevel- the log levelbyteBufFormat- the ByteBuf format
-
-
Method Detail
-
byteBufFormat
public ByteBufFormat byteBufFormat()
Returns theByteBufFormatthat this handler uses to log
-
channelRegistered
public void channelRegistered(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelRegisteredin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
channelUnregistered
public void channelUnregistered(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelUnregisteredin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
channelActive
public void channelActive(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelActivein interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelInactivein interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty5.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception- Specified by:
exceptionCaughtin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty5.channel.ChannelHandlerContext ctx, Object evt) throws Exception- Specified by:
userEventTriggeredin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
bind
public io.netty5.util.concurrent.Future<Void> bind(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress localAddress)
- Specified by:
bindin interfaceio.netty5.channel.ChannelHandler
-
connect
public io.netty5.util.concurrent.Future<Void> connect(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)
- Specified by:
connectin interfaceio.netty5.channel.ChannelHandler
-
disconnect
public io.netty5.util.concurrent.Future<Void> disconnect(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
disconnectin interfaceio.netty5.channel.ChannelHandler
-
close
public io.netty5.util.concurrent.Future<Void> close(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
closein interfaceio.netty5.channel.ChannelHandler
-
deregister
public io.netty5.util.concurrent.Future<Void> deregister(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
deregisterin interfaceio.netty5.channel.ChannelHandler
-
channelReadComplete
public void channelReadComplete(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelReadCompletein interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
channelRead
public void channelRead(io.netty5.channel.ChannelHandlerContext ctx, Object msg) throws Exception- Specified by:
channelReadin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
write
public io.netty5.util.concurrent.Future<Void> write(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
- Specified by:
writein interfaceio.netty5.channel.ChannelHandler
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty5.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelWritabilityChangedin interfaceio.netty5.channel.ChannelHandler- Throws:
Exception
-
flush
public void flush(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
flushin interfaceio.netty5.channel.ChannelHandler
-
format
protected String format(io.netty5.channel.ChannelHandlerContext ctx, String eventName)
Formats an event and returns the formatted message.- Parameters:
eventName- the name of the event
-
format
protected String format(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object arg)
Formats an event and returns the formatted message.- Parameters:
eventName- the name of the eventarg- the argument of the event
-
format
protected String format(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)
Formats an event and returns the formatted message. This method is currently only used for formattingChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress).- Parameters:
eventName- the name of the eventfirstArg- the first argument of the eventsecondArg- the second argument of the event
-
-