1 package org.slf4j.event;
2
3 import java.util.Queue;
4
5 import org.slf4j.Marker;
6 import org.slf4j.helpers.LegacyAbstractLogger;
7 import org.slf4j.helpers.SubstituteLogger;
8
9
10
11
12
13
14
15
16
17
18
19 public class EventRecordingLogger extends LegacyAbstractLogger {
20
21 private static final long serialVersionUID = -176083308134819629L;
22
23 String name;
24 SubstituteLogger logger;
25 Queue<SubstituteLoggingEvent> eventQueue;
26
27
28 final static boolean RECORD_ALL_EVENTS = true;
29
30 public EventRecordingLogger(SubstituteLogger logger, Queue<SubstituteLoggingEvent> eventQueue) {
31 this.logger = logger;
32 this.name = logger.getName();
33 this.eventQueue = eventQueue;
34 }
35
36 public String getName() {
37 return name;
38 }
39
40 public boolean isTraceEnabled() {
41 return RECORD_ALL_EVENTS;
42 }
43
44 public boolean isDebugEnabled() {
45 return RECORD_ALL_EVENTS;
46 }
47
48 public boolean isInfoEnabled() {
49 return RECORD_ALL_EVENTS;
50 }
51
52 public boolean isWarnEnabled() {
53 return RECORD_ALL_EVENTS;
54 }
55
56 public boolean isErrorEnabled() {
57 return RECORD_ALL_EVENTS;
58 }
59
60
61 protected void handleNormalizedLoggingCall(Level level, Marker marker, String msg, Object[] args, Throwable throwable) {
62 SubstituteLoggingEvent loggingEvent = new SubstituteLoggingEvent();
63 loggingEvent.setTimeStamp(System.currentTimeMillis());
64 loggingEvent.setLevel(level);
65 loggingEvent.setLogger(logger);
66 loggingEvent.setLoggerName(name);
67 if (marker != null) {
68 loggingEvent.addMarker(marker);
69 }
70 loggingEvent.setMessage(msg);
71 loggingEvent.setThreadName(Thread.currentThread().getName());
72
73 loggingEvent.setArgumentArray(args);
74 loggingEvent.setThrowable(throwable);
75
76 eventQueue.add(loggingEvent);
77
78 }
79
80 @Override
81 protected String getFullyQualifiedCallerName() {
82 return null;
83 }
84 }