@@ -55,23 +55,27 @@ final void setUpSpec() throws Exception {
55
55
@ Test
56
56
void testMetadata () throws Exception {
57
57
debug ("test" );
58
- assertThat (getAndValidateLastLogLine ().get ("process.thread.name" ).textValue ()).isEqualTo (Thread .currentThread ().getName ());
59
- assertThat (getAndValidateLastLogLine ().get ("service.name" ).textValue ()).isEqualTo ("test" );
60
- assertThat (getAndValidateLastLogLine ().get ("service.node.name" ).textValue ()).isEqualTo ("test-node" );
61
- assertThat (Instant .parse (getAndValidateLastLogLine ().get ("@timestamp" ).textValue ())).isCloseTo (Instant .now (), within (1 , ChronoUnit .MINUTES ));
62
- assertThat (getAndValidateLastLogLine ().get ("log.level" ).textValue ()).isIn ("DEBUG" , "FINE" );
63
- assertThat (getAndValidateLastLogLine ().get ("log.logger" )).isNotNull ();
64
- assertThat (getAndValidateLastLogLine ().get ("event.dataset" ).textValue ()).isEqualTo ("testdataset" );
65
- assertThat (getAndValidateLastLogLine ().get ("ecs.version" ).textValue ()).isEqualTo ("1.2.0" );
66
- validateLog (getAndValidateLastLogLine ());
58
+ JsonNode logLine = getAndValidateLastLogLine ();
59
+ System .out .println (logLine .toPrettyString ());
60
+ assertThat (logLine .get ("process.thread.name" ).textValue ()).isEqualTo (Thread .currentThread ().getName ());
61
+ assertThat (logLine .get ("service.name" ).textValue ()).isEqualTo ("test" );
62
+ assertThat (logLine .get ("service.node.name" ).textValue ()).isEqualTo ("test-node" );
63
+ assertThat (Instant .parse (logLine .get ("@timestamp" ).textValue ())).isCloseTo (Instant .now (), within (1 , ChronoUnit .MINUTES ));
64
+ assertThat (logLine .get ("log.level" ).textValue ()).isIn ("DEBUG" , "FINE" );
65
+ assertThat (logLine .get ("log.logger" )).isNotNull ();
66
+ assertThat (logLine .get ("event.dataset" ).textValue ()).isEqualTo ("testdataset" );
67
+ assertThat (logLine .get ("ecs.version" ).textValue ()).isEqualTo ("1.2.0" );
68
+ validateLog (logLine );
67
69
}
68
70
69
71
@ Test
70
72
protected final void testAdditionalFields () throws Exception {
71
73
debug ("test" );
72
- assertThat (getAndValidateLastLogLine ().get ("key1" ).textValue ()).isEqualTo ("value1" );
73
- assertThat (getAndValidateLastLogLine ().get ("key2" ).textValue ()).isEqualTo ("value2" );
74
- validateLog (getAndValidateLastLogLine ());
74
+ JsonNode logLine = getAndValidateLastLogLine ();
75
+ System .out .println (logLine .toPrettyString ());
76
+ assertThat (logLine .get ("key1" ).textValue ()).isEqualTo ("value1" );
77
+ assertThat (logLine .get ("key2" ).textValue ()).isEqualTo ("value2" );
78
+ validateLog (logLine );
75
79
}
76
80
77
81
@ Test
@@ -189,6 +193,7 @@ void testMdc() throws Exception {
189
193
void testLogException () throws Exception {
190
194
error ("test" , new RuntimeException ("test" ));
191
195
JsonNode log = getAndValidateLastLogLine ();
196
+ System .out .println (log .toPrettyString ());
192
197
assertThat (log .get ("log.level" ).textValue ()).isIn ("ERROR" , "SEVERE" );
193
198
assertThat (log .get ("error.message" ).textValue ()).isEqualTo ("test" );
194
199
assertThat (log .get ("error.type" ).textValue ()).isEqualTo (RuntimeException .class .getName ());
@@ -205,9 +210,11 @@ void testLogExceptionNullMessage() throws Exception {
205
210
@ Test
206
211
void testLogOrigin () throws Exception {
207
212
debug ("test" );
208
- assertThat (getAndValidateLastLogLine ().at ("/log/origin/file/name" ).textValue ()).endsWith (".java" );
209
- assertThat (getAndValidateLastLogLine ().at ("/log/origin/function" ).textValue ()).isEqualTo ("debug" );
210
- assertThat (getAndValidateLastLogLine ().at ("/log/origin/file/line" ).intValue ()).isPositive ();
213
+ JsonNode logLine = getAndValidateLastLogLine ();
214
+ System .out .println (logLine .toPrettyString ());
215
+ assertThat (logLine .at ("/log/origin/file/name" ).textValue ()).endsWith (".java" );
216
+ assertThat (logLine .at ("/log/origin/function" ).textValue ()).isEqualTo ("debug" );
217
+ assertThat (logLine .at ("/log/origin/file/line" ).intValue ()).isPositive ();
211
218
}
212
219
213
220
public boolean putMdc (String key , String value ) {
0 commit comments