1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.status;
15
16 import ch.qos.logback.core.Context;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public class StatusUtil {
22
23 static public List<Status> filterStatusListByTimeThreshold(List<Status> rawList, long threshold) {
24 List<Status> filteredList = new ArrayList<Status>();
25 for (Status s : rawList) {
26 if (s.getDate() >= threshold)
27 filteredList.add(s);
28 }
29 return filteredList;
30 }
31
32 static public void addStatus(Context context, Status status) {
33 if (context == null) {
34 return;
35 }
36 StatusManager sm = context.getStatusManager();
37 if (sm != null) {
38 sm.add(status);
39 }
40 }
41
42 static public void addInfo(Context context, Object caller, String msg) {
43 addStatus(context, new InfoStatus(msg, caller));
44 }
45
46 static public void addWarn(Context context, Object caller, String msg) {
47 addStatus(context, new WarnStatus(msg, caller));
48 }
49
50 static public void addError(Context context, Object caller, String msg,
51 Throwable t) {
52 addStatus(context, new ErrorStatus(msg, caller, t));
53 }
54 }