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;
		}
	}
@Test
	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);
	}