Transport { public T wiretap(boolean enable) { if (enable) { T dup = duplicate(); dup.configuration().loggingHandler = configuration().defaultLoggingHandler(); return dup; } else if (configuration().loggingHandler != null) { T dup = duplicate(); dup.configuration().loggingHandler = null; return dup; } else { @SuppressWarnings("unchecked") T dup = (T) this; return dup; } }  T attr(AttributeKey<A> key, @Nullable A value); T bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier); T channelGroup(ChannelGroup channelGroup); abstract C configuration(); T doOnChannelInit(ChannelPipelineConfigurer doOnChannelInit); T metrics(boolean enable, Supplier<? extends ChannelMetricsRecorder> recorder); T observe(ConnectionObserver observer); @SuppressWarnings("ReferenceEquality") T option(ChannelOption<O> key, @Nullable O value); T runOn(EventLoopGroup eventLoopGroup); T runOn(LoopResources channelResources); T runOn(LoopResources loopResources, boolean preferNative); T wiretap(boolean enable); T wiretap(String category); T wiretap(String category, LogLevel level); final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format); final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format, Charset charset);  }
@Test public void testWiretap() { TestTransportConfig config = new TestTransportConfig(Collections.emptyMap()); TestTransport transport = new TestTransport(config); doTestWiretap(transport.wiretap(true), LogLevel.DEBUG, ByteBufFormat.HEX_DUMP); doTestWiretap(transport.wiretap("category"), LogLevel.DEBUG, ByteBufFormat.HEX_DUMP); doTestWiretap(transport.wiretap("category", LogLevel.DEBUG), LogLevel.DEBUG, ByteBufFormat.HEX_DUMP); doTestWiretap(transport.wiretap("category", LogLevel.INFO), LogLevel.INFO, ByteBufFormat.HEX_DUMP); doTestWiretap( transport.wiretap("category", LogLevel.INFO, AdvancedByteBufFormat.HEX_DUMP), LogLevel.INFO, ByteBufFormat.HEX_DUMP); doTestWiretap( transport.wiretap("category", LogLevel.DEBUG, AdvancedByteBufFormat.SIMPLE), LogLevel.DEBUG, ByteBufFormat.SIMPLE); doTestWiretapForTextualLogger( transport.wiretap("category", LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL), LogLevel.DEBUG); doTestWiretapForTextualLogger( transport.wiretap("category", LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL, Charset.defaultCharset()), LogLevel.DEBUG); }