1
2
3
4
5
6
7
8
9
10
11 package ch.qos.logback.classic.db;
12
13 import ch.qos.logback.classic.spi.LoggingEvent;
14 import ch.qos.logback.classic.spi.ThrowableDataPoint;
15
16
17
18
19
20 public class DBHelper {
21
22 public static short PROPERTIES_EXIST = 0x01;
23 public static short EXCEPTION_EXISTS = 0x02;
24
25 public static short computeReferenceMask(LoggingEvent event) {
26 short mask = 0;
27
28 int mdcPropSize = 0;
29 if (event.getMDCPropertyMap() != null) {
30 mdcPropSize = event.getMDCPropertyMap().keySet().size();
31 }
32 int contextPropSize = 0;
33 if (event.getLoggerRemoteView().getLoggerContextView().getPropertyMap() != null) {
34 contextPropSize = event.getLoggerRemoteView().getLoggerContextView()
35 .getPropertyMap().size();
36 }
37
38 if (mdcPropSize > 0 || contextPropSize > 0) {
39 mask = PROPERTIES_EXIST;
40 }
41 if (event.getThrowableProxy() != null) {
42 ThrowableDataPoint[] tdpArray = event.getThrowableProxy().getThrowableDataPointArray();
43 if (tdpArray != null) {
44 mask |= EXCEPTION_EXISTS;
45 }
46 }
47 return mask;
48 }
49 }