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