/
LogSummary.java
147 lines (111 loc) · 3.5 KB
/
LogSummary.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.log4j.Level;
import com.google.gson.annotations.Expose;
public class LogSummary implements Comparable<LogSummary> {
@Expose
private Level level;
@Expose
private String mostRecentThreadName;
private Throwable throwable;
@Expose
private long firstOccurranceTime;
@Expose
private long mostRecentTime;
@Expose
private int count;
@Expose
private String message;
@Expose
private String stackTrace;
@Expose
private Integer levelInt;
public void setLevel(Level level) {
this.level = level;
}
public Level getLevel() {
return level;
}
public String getStackTrace() {
if (this.stackTrace == null && this.throwable != null) {
StringWriter st = new StringWriter();
throwable.printStackTrace(new PrintWriter(st));
this.stackTrace = st.toString();
}
return this.stackTrace;
}
public void setStackTrace(String st) {
this.stackTrace = st;
}
public Integer getLevelInt() {
return this.levelInt != null ? this.levelInt : this.level != null ? this.level.toInt() : 0;
}
public void setLevelInt(Integer levelInt) {
this.levelInt = levelInt;
}
public long getFirstOccurranceTime() {
return firstOccurranceTime;
}
public void setFirstOccurranceTime(long firstOccurranceDate) {
this.firstOccurranceTime = firstOccurranceDate;
}
public long getMostRecentTime() {
return mostRecentTime;
}
public void setMostRecentTime(long mostRecentDate) {
this.mostRecentTime = mostRecentDate;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public void setMostRecentThreadName(String mostRecentThreadName) {
this.mostRecentThreadName = mostRecentThreadName;
}
public String getMostRecentThreadName() {
return mostRecentThreadName;
}
public void setThrowable(Throwable throwable) {
this.throwable = throwable;
}
public Throwable getThrowable() {
return throwable;
}
@Override
public int compareTo(LogSummary other) {
if (mostRecentTime == other.mostRecentTime) {
return 0;
} else {
return mostRecentTime > other.mostRecentTime ? 1 : -1;
}
}
}