Home / Class/ LoggingHandler Class — netty Architecture

LoggingHandler Class — netty Architecture

Architecture documentation for the LoggingHandler class in LoggingHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7a529b9c_2743_f7e2_99c5_394498f7a926["LoggingHandler"]
  e01c08ed_691b_8505_0e9b_c7e175e532bf["LoggingHandler.java"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|defined in| e01c08ed_691b_8505_0e9b_c7e175e532bf
  fce257d6_9649_79bc_8503_75e0106ff5c9["write()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| fce257d6_9649_79bc_8503_75e0106ff5c9
  2ff37f87_6b6f_50ba_e372_53766eac9829["flush()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 2ff37f87_6b6f_50ba_e372_53766eac9829
  50340ecc_58ae_509a_0d01_348c4eab03ca["bind()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 50340ecc_58ae_509a_0d01_348c4eab03ca
  77697fa2_a84b_d536_cbfd_dc8104359e0f["connect()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 77697fa2_a84b_d536_cbfd_dc8104359e0f
  8da5b422_ecbc_677c_9229_6f5dfac65c9a["disconnect()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 8da5b422_ecbc_677c_9229_6f5dfac65c9a
  950d32d3_6f63_242a_fbb7_c79e74f506bc["close()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 950d32d3_6f63_242a_fbb7_c79e74f506bc
  c9caabdd_0f3a_1759_aa83_c62feed1a4de["deregister()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| c9caabdd_0f3a_1759_aa83_c62feed1a4de
  134e44b1_ef76_da5e_26aa_090a34903514["read()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 134e44b1_ef76_da5e_26aa_090a34903514
  f528abe0_7f8d_b232_8571_eb7d8964b3e7["channelWritabilityChanged()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| f528abe0_7f8d_b232_8571_eb7d8964b3e7
  c1f67cc1_f695_1192_a4bb_8582384bf673["handlerAdded()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| c1f67cc1_f695_1192_a4bb_8582384bf673
  86c7634e_941a_c88e_4ee6_804ce283d21f["handlerRemoved()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 86c7634e_941a_c88e_4ee6_804ce283d21f
  3a95096e_c601_6953_f574_7ee82632ff67["exceptionCaught()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 3a95096e_c601_6953_f574_7ee82632ff67
  2be934dd_5c97_f484_2dff_ba37566f09ae["channelRegistered()"]
  7a529b9c_2743_f7e2_99c5_394498f7a926 -->|method| 2be934dd_5c97_f484_2dff_ba37566f09ae

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/LoggingHandler.java lines 22–171

final class LoggingHandler implements ChannelInboundHandler, ChannelOutboundHandler {

    enum Event { WRITE, FLUSH, BIND, CONNECT, DISCONNECT, CLOSE, DEREGISTER, READ, WRITABILITY,
        HANDLER_ADDED, HANDLER_REMOVED, EXCEPTION, READ_COMPLETE, REGISTERED, UNREGISTERED, ACTIVE, INACTIVE,
        USER }

    private StringBuilder log = new StringBuilder();

    private final EnumSet<Event> interest = EnumSet.allOf(Event.class);

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        log(Event.WRITE);
        ctx.write(msg, promise);
    }

    @Override
    public void flush(ChannelHandlerContext ctx) throws Exception {
        log(Event.FLUSH);
        ctx.flush();
    }

    @Override
    public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
            throws Exception {
        log(Event.BIND, "localAddress=" + localAddress);
        ctx.bind(localAddress, promise);
    }

    @Override
    public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress,
            ChannelPromise promise) throws Exception {
        log(Event.CONNECT, "remoteAddress=" + remoteAddress + " localAddress=" + localAddress);
        ctx.connect(remoteAddress, localAddress, promise);
    }

    @Override
    public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        log(Event.DISCONNECT);
        ctx.disconnect(promise);
    }

    @Override
    public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        log(Event.CLOSE);
        ctx.close(promise);
    }

    @Override
    public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        log(Event.DEREGISTER);
        ctx.deregister(promise);
    }

    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        log(Event.READ);
        ctx.read();
    }

    @Override
    public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
        log(Event.WRITABILITY, "writable=" + ctx.channel().isWritable());
        ctx.fireChannelWritabilityChanged();
    }

    @Override
    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
        log(Event.HANDLER_ADDED);
    }

    @Override
    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
        log(Event.HANDLER_REMOVED);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        log(Event.EXCEPTION, cause.toString());
    }

Frequently Asked Questions

What is the LoggingHandler class?
LoggingHandler is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/LoggingHandler.java.
Where is LoggingHandler defined?
LoggingHandler is defined in transport/src/test/java/io/netty/channel/LoggingHandler.java at line 22.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free