@Test public void logging() { ChannelTracer tracer = new ChannelTracer( logId, 1, 3L, "fooType"); ChannelLoggerImpl logger = new ChannelLoggerImpl(tracer, clock.getTimeProvider()); ChannelStats.Builder builder = new ChannelStats.Builder(); logs.clear(); clock.forwardNanos(100); logger.log(ChannelLogLevel.ERROR, "Error message"); tracer.updateBuilder(builder); ChannelStats stats = builder.build(); Event event = new Event.Builder() .setDescription("Error message") .setSeverity(Severity.CT_ERROR) .setTimestampNanos(100) .build(); assertThat(stats.channelTrace.events).containsExactly(event); assertThat(logs).contains("FINE: " + logPrefix + "Error message"); clock.forwardNanos(100); logger.log(ChannelLogLevel.WARNING, "Warning message"); tracer.updateBuilder(builder); stats = builder.build(); event = new Event.Builder() .setDescription("Warning message") .setSeverity(Severity.CT_WARNING) .setTimestampNanos(200) .build(); assertThat(stats.channelTrace.events).containsExactly(event); assertThat(logs).contains("FINER: " + logPrefix + "Warning message"); clock.forwardNanos(100); logger.log(ChannelLogLevel.INFO, "Info message"); tracer.updateBuilder(builder); stats = builder.build(); event = new Event.Builder() .setDescription("Info message") .setSeverity(Severity.CT_INFO) .setTimestampNanos(300) .build(); assertThat(stats.channelTrace.events).containsExactly(event); assertThat(logs).contains("FINEST: " + logPrefix + "Info message"); clock.forwardNanos(100); logger.log(ChannelLogLevel.DEBUG, "Debug message"); tracer.updateBuilder(builder); stats = builder.build(); assertThat(stats.channelTrace.events).containsExactly(event); assertThat(logs).contains("FINEST: " + logPrefix + "Debug message"); }
@Override public void log(ChannelLogLevel level, String msg) { Level javaLogLevel = toJavaLogLevel(level); if (ChannelTracer.logger.isLoggable(javaLogLevel)) { tracer.logOnly(javaLogLevel, msg); } if (isTraceable(level)) { trace(level, msg); } }
ChannelLoggerImpl extends ChannelLogger { @Override public void log(ChannelLogLevel level, String msg) { Level javaLogLevel = toJavaLogLevel(level); if (ChannelTracer.logger.isLoggable(javaLogLevel)) { tracer.logOnly(javaLogLevel, msg); } if (isTraceable(level)) { trace(level, msg); } } }
ChannelLoggerImpl extends ChannelLogger { @Override public void log(ChannelLogLevel level, String msg) { Level javaLogLevel = toJavaLogLevel(level); if (ChannelTracer.logger.isLoggable(javaLogLevel)) { tracer.logOnly(javaLogLevel, msg); } if (isTraceable(level)) { trace(level, msg); } } ChannelLoggerImpl(ChannelTracer tracer, TimeProvider time); }
ChannelLoggerImpl extends ChannelLogger { @Override public void log(ChannelLogLevel level, String msg) { Level javaLogLevel = toJavaLogLevel(level); if (ChannelTracer.logger.isLoggable(javaLogLevel)) { tracer.logOnly(javaLogLevel, msg); } if (isTraceable(level)) { trace(level, msg); } } ChannelLoggerImpl(ChannelTracer tracer, TimeProvider time); @Override void log(ChannelLogLevel level, String msg); @Override void log(ChannelLogLevel level, String messageFormat, Object... args); }
ChannelLoggerImpl extends ChannelLogger { @Override public void log(ChannelLogLevel level, String msg) { Level javaLogLevel = toJavaLogLevel(level); if (ChannelTracer.logger.isLoggable(javaLogLevel)) { tracer.logOnly(javaLogLevel, msg); } if (isTraceable(level)) { trace(level, msg); } } ChannelLoggerImpl(ChannelTracer tracer, TimeProvider time); @Override void log(ChannelLogLevel level, String msg); @Override void log(ChannelLogLevel level, String messageFormat, Object... args);  }