@Test public void testErrorHandling() { Throwable cause = new Throwable("Original Cause"); LogData data = FakeLogData.withPrintfStyle("Hello World") .addMetadata(LogContext.Key.LOG_CAUSE, cause); RuntimeException error = new RuntimeException("Runtime Error"); LogRecord record = SimpleLogRecord.error(error, data); assertThat(record.getLevel()).isEqualTo(Level.WARNING); assertThat(record.getThrown()).isEqualTo(error); assertThat(record.getMessage()).contains("message: Hello World"); assertThat(record.getMessage()).contains("level: INFO"); assertThat(record.getMessage()).contains("Original Cause"); }
public static SimpleLogRecord error(RuntimeException error, LogData data) { return new SimpleLogRecord(error, data); }
SimpleLogRecord extends AbstractLogRecord implements SimpleLogHandler { public static SimpleLogRecord error(RuntimeException error, LogData data) { return new SimpleLogRecord(error, data); } }
SimpleLogRecord extends AbstractLogRecord implements SimpleLogHandler { public static SimpleLogRecord error(RuntimeException error, LogData data) { return new SimpleLogRecord(error, data); } private  SimpleLogRecord(LogData data); private  SimpleLogRecord(RuntimeException error, LogData data); }
SimpleLogRecord extends AbstractLogRecord implements SimpleLogHandler { public static SimpleLogRecord error(RuntimeException error, LogData data) { return new SimpleLogRecord(error, data); } private  SimpleLogRecord(LogData data); private  SimpleLogRecord(RuntimeException error, LogData data); static SimpleLogRecord create(LogData data); static SimpleLogRecord error(RuntimeException error, LogData data); @Override void handleFormattedLogMessage(Level level, String message, @NullableDecl Throwable thrown); }
SimpleLogRecord extends AbstractLogRecord implements SimpleLogHandler { public static SimpleLogRecord error(RuntimeException error, LogData data) { return new SimpleLogRecord(error, data); } private  SimpleLogRecord(LogData data); private  SimpleLogRecord(RuntimeException error, LogData data); static SimpleLogRecord create(LogData data); static SimpleLogRecord error(RuntimeException error, LogData data); @Override void handleFormattedLogMessage(Level level, String message, @NullableDecl Throwable thrown);  }