1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.boolex;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.slf4j.Marker;
20
21 import ch.qos.logback.classic.spi.ILoggingEvent;
22 import ch.qos.logback.core.boolex.EvaluationException;
23 import ch.qos.logback.core.boolex.EventEvaluatorBase;
24
25
26
27
28
29
30
31 public class OnMarkerEvaluator extends EventEvaluatorBase<ILoggingEvent> {
32
33 List<String> markerList = new ArrayList<String>();
34
35 public void addMarker(String markerStr) {
36 markerList.add(markerStr);
37 }
38
39
40
41
42
43 public boolean evaluate(ILoggingEvent event) throws NullPointerException, EvaluationException {
44
45 List<Marker> markerListInEvent = event.getMarkerList();
46 if (markerListInEvent == null || markerListInEvent.isEmpty()) {
47 return false;
48 }
49
50 for (String markerStr : markerList) {
51 for (Marker markerInEvent : markerListInEvent) {
52 if (markerInEvent.contains(markerStr)) {
53 return true;
54 }
55 }
56 }
57 return false;
58 }
59 }