1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.microemu.log;
23
24
25
26
27
28 public class LoggingEvent {
29
30 public final static int DEBUG = 1;
31
32 public final static int INFO = 2;
33
34 public final static int WARN = 3;
35
36 public final static int ERROR = 4;
37
38 protected int level;
39
40 protected String message;
41
42 protected StackTraceElement location;
43
44 protected boolean hasData = false;
45
46 protected Object data;
47
48 protected Throwable throwable;
49
50 protected long eventTime;
51
52
53 public LoggingEvent() {
54 this.eventTime = System.currentTimeMillis();
55 }
56
57 public LoggingEvent(int level, String message, StackTraceElement location, Throwable throwable) {
58 this();
59 this.level = level;
60 this.message = message;
61 this.location = location;
62 this.throwable = throwable;
63 }
64
65 public LoggingEvent(int level, String message, StackTraceElement location, Throwable throwable, Object data) {
66 this(level, message, location, throwable);
67 setData(data);
68 }
69
70 public Object getData() {
71 return this.data;
72 }
73
74 public void setData(Object data) {
75 this.data = data;
76 this.hasData = true;
77 }
78
79 public boolean hasData() {
80 return this.hasData;
81 }
82
83 public String getFormatedData() {
84 if (hasData()) {
85 if (getData() == null) {
86 return "{null}";
87 } else {
88 return getData().toString();
89 }
90 } else {
91 return "";
92 }
93 }
94
95 public long getEventTime() {
96 return this.eventTime;
97 }
98
99 public int getLevel() {
100 return this.level;
101 }
102
103 public StackTraceElement getLocation() {
104 return this.location;
105 }
106
107 public String getMessage() {
108 return this.message;
109 }
110
111 public Throwable getThrowable() {
112 return this.throwable;
113 }
114
115 }