1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.async;
18
19 import java.util.Map;
20
21 import org.apache.logging.log4j.Level;
22 import org.apache.logging.log4j.Marker;
23 import org.apache.logging.log4j.ThreadContext.ContextStack;
24 import org.apache.logging.log4j.message.Message;
25
26 import com.lmax.disruptor.EventTranslator;
27
28
29
30
31
32
33
34 public class RingBufferLogEventTranslator implements
35 EventTranslator<RingBufferLogEvent> {
36
37 private AsyncLogger asyncLogger;
38 private String loggerName;
39 private Marker marker;
40 private String fqcn;
41 private Level level;
42 private Message message;
43 private Throwable thrown;
44 private Map<String, String> contextMap;
45 private ContextStack contextStack;
46 private String threadName;
47 private StackTraceElement location;
48 private long currentTimeMillis;
49
50
51 @Override
52 public void translateTo(final RingBufferLogEvent event, final long sequence) {
53 event.setValues(asyncLogger, loggerName, marker, fqcn, level, message,
54 thrown, contextMap, contextStack, threadName, location,
55 currentTimeMillis);
56 clear();
57 }
58
59
60
61
62
63 private void clear() {
64 setValues(null,
65 null,
66 null,
67 null,
68 null,
69 null,
70 null,
71 null,
72 null,
73 null,
74 null,
75 0
76 );
77 }
78
79 public void setValues(final AsyncLogger asyncLogger, final String loggerName,
80 final Marker marker, final String fqcn, final Level level, final Message message,
81 final Throwable thrown, final Map<String, String> contextMap,
82 final ContextStack contextStack, final String threadName,
83 final StackTraceElement location, final long currentTimeMillis) {
84 this.asyncLogger = asyncLogger;
85 this.loggerName = loggerName;
86 this.marker = marker;
87 this.fqcn = fqcn;
88 this.level = level;
89 this.message = message;
90 this.thrown = thrown;
91 this.contextMap = contextMap;
92 this.contextStack = contextStack;
93 this.threadName = threadName;
94 this.location = location;
95 this.currentTimeMillis = currentTimeMillis;
96 }
97
98 }