LogEvent { void appendTrace(StringBuilder builder, long startTime) { appendDuration(builder, time - startTime); builder.append(' '); if (level != LogLevel.DEBUG) builder.append(level.name()).append(' '); builder.append(logger) .append(" - "); if (marker != null) builder.append('[').append(marker.getName()).append("] "); LogManager.FILTER.append(builder, message, arguments); builder.append(System.lineSeparator()); if (exception != null) builder.append(Exceptions.stackTrace(exception)); } LogEvent(String logger, Marker marker, LogLevel level, String message, Object[] arguments, Throwable exception);   }
@Test void appendTrace() { var event = new LogEvent("logger", Markers.errorCode("ERROR_CODE"), LogLevel.WARN, "message-{}", new Object[]{1}, new Error()); var builder = new StringBuilder(); event.appendTrace(builder, System.nanoTime()); assertThat(builder.toString()).contains("WARN logger - [ERROR_CODE] message-1"); builder = new StringBuilder(); event = new LogEvent("logger", null, LogLevel.DEBUG, "message", null, null); event.appendTrace(builder, System.nanoTime()); assertThat(builder.toString()).contains("logger - message"); }