1
2
3
4
5
6
7
8
9
10
11
12
13
14 package chapter4.mail;
15
16 import ch.qos.logback.core.boolex.EvaluationException;
17 import ch.qos.logback.core.boolex.EventEvaluator;
18 import ch.qos.logback.core.spi.ContextAwareBase;
19
20
21
22
23
24 public class CounterBasedEvaluator extends ContextAwareBase implements EventEvaluator {
25
26 static int LIMIT = 1024;
27 int counter = 0;
28 String name;
29 boolean started;
30
31 public boolean evaluate(Object event) throws NullPointerException,
32 EvaluationException {
33 counter++;
34
35 if (counter == LIMIT) {
36 counter = 0;
37
38 return true;
39 } else {
40 return false;
41 }
42 }
43
44 public String getName() {
45 return name;
46 }
47
48 public void setName(String name) {
49 this.name = name;
50 }
51
52 public boolean isStarted() {
53 return started;
54 }
55
56 public void start() {
57 started = true;
58 }
59
60 public void stop() {
61 started = false;
62 }
63 }