1
2
3
4
5
6
7
8
9
10 package ch.qos.logback.classic.pattern;
11
12 import ch.qos.logback.classic.spi.LoggingEvent;
13
14 public class RelativeTimeConverter extends ClassicConverter {
15
16 long lastTimestamp = -1;
17 String timesmapStr = null;
18
19 public String convert(LoggingEvent event) {
20 long timestamp = event.getTimeStamp();
21
22
23
24 if(timestamp == lastTimestamp) {
25 return timesmapStr;
26 } else {
27 lastTimestamp = timestamp;
28 timesmapStr = Long.toString(timestamp - LoggingEvent.getStartTime());
29 return timesmapStr;
30 }
31 }
32 }