Skip to content

Commit

Permalink
use timestamp.toEpochMilli() instead of Instant (#49)
Browse files Browse the repository at this point in the history
* use timestamp.toEpochMilli() instead of Instant to avoid teragrep/rlo_14#10

* test that timestamp matches to an expected pattern
  • Loading branch information
kortemik authored Dec 4, 2024
1 parent 5c610f6 commit 763769a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public SyslogRecordTimestamp(SyslogRecord syslogRecord, Instant timestamp) {

@Override
public SyslogMessage getRecord() {
return syslogRecord.getRecord().withTimestamp(timestamp);
return syslogRecord.getRecord().withTimestamp(timestamp.toEpochMilli());
}
}
5 changes: 5 additions & 0 deletions src/test/java/com/teragrep/jla_01/RlpLogbackAppenderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public void testDefaultSyslogMessage() {

Assertions.assertEquals("localhost", rfc5424Frame.hostname.toString());
Assertions.assertEquals("appName", rfc5424Frame.appName.toString());

Pattern timestampPattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z");

Assertions.assertTrue(timestampPattern.matcher(rfc5424Frame.timestamp.toString()).matches());

Assertions.assertEquals("DEBUG logger - "+testPayload+"\n", rfc5424Frame.msg.toString());
}

Expand Down

0 comments on commit 763769a

Please sign in to comment.