- java.lang.Object
-
- io.netty5.handler.logging.LoggingHandler
-
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
public class LoggingHandler extends Object implements io.netty5.channel.ChannelHandler
AChannelHandler
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty5.util.internal.logging.InternalLogLevel
internalLevel
protected io.netty5.util.internal.logging.InternalLogger
logger
-
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(BufferFormat 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, BufferFormat bufferFormat)
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, BufferFormat bufferFormat)
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, BufferFormat bufferFormat)
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)
BufferFormat
bufferFormat()
Returns theBufferFormat
that this handler uses to logvoid
channelActive(io.netty5.channel.ChannelHandlerContext ctx)
void
channelExceptionCaught(io.netty5.channel.ChannelHandlerContext ctx, Throwable cause)
void
channelInactive(io.netty5.channel.ChannelHandlerContext ctx)
void
channelInboundEvent(io.netty5.channel.ChannelHandlerContext ctx, Object evt)
void
channelRead(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
void
channelReadComplete(io.netty5.channel.ChannelHandlerContext ctx)
void
channelRegistered(io.netty5.channel.ChannelHandlerContext ctx)
void
channelUnregistered(io.netty5.channel.ChannelHandlerContext ctx)
void
channelWritabilityChanged(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)
void
flush(io.netty5.channel.ChannelHandlerContext ctx)
protected String
format(io.netty5.channel.ChannelHandlerContext ctx, String eventName)
Formats an event and returns the formatted message.protected String
format(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object arg)
Formats an event and returns the formatted message.protected String
format(io.netty5.channel.ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)
Formats an event and returns the formatted message.boolean
isSharable()
LogLevel
level()
Returns theLogLevel
that this handler uses to logio.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(BufferFormat 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, BufferFormat bufferFormat)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log levelbufferFormat
- 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, BufferFormat bufferFormat)
Creates a new instance with the specified logger name.- Parameters:
clazz
- the class type to generate the logger forlevel
- the log levelbufferFormat
- 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, BufferFormat bufferFormat)
Creates a new instance with the specified logger name.- Parameters:
name
- the name of the class to use for the loggerlevel
- the log levelbufferFormat
- the ByteBuf format
-
-
Method Detail
-
isSharable
public boolean isSharable()
- Specified by:
isSharable
in interfaceio.netty5.channel.ChannelHandler
-
bufferFormat
public BufferFormat bufferFormat()
Returns theBufferFormat
that this handler uses to log
-
channelRegistered
public void channelRegistered(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelRegistered
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelUnregistered
public void channelUnregistered(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelUnregistered
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelActive
public void channelActive(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelActive
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelInactive
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelExceptionCaught
public void channelExceptionCaught(io.netty5.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
- Specified by:
channelExceptionCaught
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelInboundEvent
public void channelInboundEvent(io.netty5.channel.ChannelHandlerContext ctx, Object evt) throws Exception
- Specified by:
channelInboundEvent
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
bind
public io.netty5.util.concurrent.Future<Void> bind(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress localAddress)
- Specified by:
bind
in interfaceio.netty5.channel.ChannelHandler
-
connect
public io.netty5.util.concurrent.Future<Void> connect(io.netty5.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)
- Specified by:
connect
in interfaceio.netty5.channel.ChannelHandler
-
disconnect
public io.netty5.util.concurrent.Future<Void> disconnect(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
disconnect
in interfaceio.netty5.channel.ChannelHandler
-
close
public io.netty5.util.concurrent.Future<Void> close(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
close
in interfaceio.netty5.channel.ChannelHandler
-
deregister
public io.netty5.util.concurrent.Future<Void> deregister(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
deregister
in interfaceio.netty5.channel.ChannelHandler
-
channelReadComplete
public void channelReadComplete(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelReadComplete
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
channelRead
public void channelRead(io.netty5.channel.ChannelHandlerContext ctx, Object msg) throws Exception
- Specified by:
channelRead
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
write
public io.netty5.util.concurrent.Future<Void> write(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
- Specified by:
write
in interfaceio.netty5.channel.ChannelHandler
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelWritabilityChanged
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
flush
public void flush(io.netty5.channel.ChannelHandlerContext ctx)
- Specified by:
flush
in 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
-
-