ExecContextLogger implements Logger, Wrapper<Logger> { @Override public void trace(final String msg) { log(null, Level.TRACE, msg); } ExecContextLogger(final Logger wrapped);  ExecContextLogger(final XLog traceLogger); static ExecContextLogger from(final Logger wrapped); @Override Logger getWrapped(); @Override String getName(); boolean isEnabled(final Level level, @Nullable final Marker marker); void log(final ExecutionContext ctx, final Level level, final LogRecord log); void log(@Nullable final Marker marker, final Level level, final String msg, final Object... args); void log(final ExecutionContext ctx, @Nullable final Marker marker,
          final Level level, final String msg, final Object... args); @Override boolean isTraceEnabled(); @Override void trace(final String msg); @Override void trace(final String format, final Object arg); @Override void trace(final String format, final Object arg1, final Object arg2); @Override void trace(final String format, final Object... arguments); @Override void trace(final String msg, final Throwable t); @Override boolean isTraceEnabled(final Marker marker); @Override void trace(final Marker marker, final String msg); @Override void trace(final Marker marker, final String format, final Object arg); @Override void trace(final Marker marker, final String format, final Object arg1, final Object arg2); @Override void trace(final Marker marker, final String format, final Object... argArray); @Override void trace(final Marker marker, final String msg, final Throwable t); @Override boolean isDebugEnabled(); @Override void debug(final String msg); @Override void debug(final String format, final Object arg); @Override void debug(final String format, final Object arg1, final Object arg2); @Override void debug(final String format, final Object... arguments); @Override void debug(final String msg, final Throwable t); @Override boolean isDebugEnabled(final Marker marker); @Override void debug(final Marker marker, final String msg); @Override void debug(final Marker marker, final String format, final Object arg); @Override void debug(final Marker marker, final String format, final Object arg1, final Object arg2); @Override void debug(final Marker marker, final String format, final Object... arguments); @Override void debug(final Marker marker, final String msg, final Throwable t); @Override boolean isInfoEnabled(); @Override void info(final String msg); @Override void info(final String format, final Object arg); @Override void info(final String format, final Object arg1, final Object arg2); @Override void info(final String format, final Object... arguments); @Override void info(final String msg, final Throwable t); @Override boolean isInfoEnabled(final Marker marker); @Override void info(final Marker marker, final String msg); @Override void info(final Marker marker, final String format, final Object arg); @Override void info(final Marker marker, final String format, final Object arg1, final Object arg2); @Override void info(final Marker marker, final String format, final Object... arguments); @Override void info(final Marker marker, final String msg, final Throwable t); @Override boolean isWarnEnabled(); @Override void warn(final String msg); @Override void warn(final String format, final Object arg); @Override void warn(final String format, final Object... arguments); @Override void warn(final String format, final Object arg1, final Object arg2); @Override void warn(final String msg, final Throwable t); @Override boolean isWarnEnabled(final Marker marker); @Override void warn(final Marker marker, final String msg); @Override void warn(final Marker marker, final String format, final Object arg); @Override void warn(final Marker marker, final String format, final Object arg1, final Object arg2); @Override void warn(final Marker marker, final String format, final Object... arguments); @Override void warn(final Marker marker, final String msg, final Throwable t); @Override boolean isErrorEnabled(); @Override void error(final String msg); @Override void error(final String format, final Object arg); @Override void error(final String format, final Object arg1, final Object arg2); @Override void error(final String format, final Object... arguments); @Override void error(final String msg, final Throwable t); @Override boolean isErrorEnabled(final Marker marker); @Override void error(final Marker marker, final String msg); @Override void error(final Marker marker, final String format, final Object arg); @Override void error(final Marker marker, final String format, final Object arg1, final Object arg2); @Override void error(final Marker marker, final String format, final Object... arguments); @Override void error(final Marker marker, final String msg, final Throwable t); @Override String toString();  }
@Test @ExpectLog(level = Level.TRACE, messageRegexp = "msg1") public void testTrace() { ExecContextLogger log = new ExecContextLogger(LoggerFactory.getLogger("test")); log.trace("msg1"); List<Slf4jLogRecord> logs = new ArrayList<>(2); ExecutionContexts.current().streamLogs(logs::add); Assert.assertEquals("msg1", logs.get(0).getMessageFormat()); }
@Test public void testTrace2() { ExecContextLogger log = new ExecContextLogger(LoggerFactory.getLogger("test")); LogAssert expect = TestLoggers.sys().expect("test", Level.DEBUG, Matchers.allOf(LogMatchers.hasExtraArgument(LogAttribute.origLevel(Level.TRACE)), LogMatchers.hasMessage("msg1"))); ExecutionContext current = ExecutionContexts.current(); current.setBackendMinLogLevel("test", Level.TRACE); log.trace("msg1"); expect.assertObservation(); List<Slf4jLogRecord> logs = new ArrayList<>(2); current.streamLogs(logs::add); Assert.assertEquals("msg1", logs.get(0).getMessageFormat()); }