1 |
|
package jalview.javascript.log4j; |
2 |
|
|
3 |
|
import java.io.IOException; |
4 |
|
import java.io.ObjectInputStream; |
5 |
|
import java.io.ObjectOutputStream; |
6 |
|
import java.io.ObjectStreamException; |
7 |
|
import java.io.Serializable; |
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
@author |
19 |
|
|
|
|
| 0% |
Uncovered Elements: 89 (89) |
Complexity: 28 |
Complexity Density: 0.49 |
|
20 |
|
public class Level extends Priority implements Serializable |
21 |
|
{ |
22 |
|
|
23 |
|
private static final String ALL_NAME = "ALL"; |
24 |
|
|
25 |
|
private static final String TRACE_NAME = "TRACE"; |
26 |
|
|
27 |
|
private static final String DEBUG_NAME = "DEBUG"; |
28 |
|
|
29 |
|
private static final String INFO_NAME = "INFO"; |
30 |
|
|
31 |
|
private static final String WARN_NAME = "WARN"; |
32 |
|
|
33 |
|
private static final String ERROR_NAME = "ERROR"; |
34 |
|
|
35 |
|
private static final String FATAL_NAME = "FATAL"; |
36 |
|
|
37 |
|
private static final String OFF_NAME = "OFF"; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@since |
43 |
|
|
44 |
|
public static final int TRACE_INT = 5000; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
final static public Level OFF = new Level(OFF_INT, OFF_NAME, 0); |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
final static public Level FATAL = new Level(FATAL_INT, FATAL_NAME, 0); |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
final static public Level ERROR = new Level(ERROR_INT, ERROR_NAME, 3); |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
final static public Level WARN = new Level(WARN_INT, WARN_NAME, 4); |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
final static public Level INFO = new Level(INFO_INT, INFO_NAME, 6); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
final static public Level DEBUG = new Level(DEBUG_INT, DEBUG_NAME, 7); |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@since |
86 |
|
|
87 |
|
public static final Level TRACE = new Level(TRACE_INT, TRACE_NAME, 7); |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
final static public Level ALL = new Level(ALL_INT, ALL_NAME, 7); |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
static final long serialVersionUID = 3491141966387921974L; |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
protected Level(int level, String levelStr, int syslogEquivalent)... |
104 |
|
{ |
105 |
0 |
super(level, levelStr, syslogEquivalent); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
@link |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
public static Level toLevel(String sArg)... |
113 |
|
{ |
114 |
0 |
return toLevel(sArg, Level.DEBUG); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@link |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
public static Level toLevel(int val)... |
122 |
|
{ |
123 |
0 |
return toLevel(val, Level.DEBUG); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 9 |
Complexity Density: 0.47 |
|
130 |
0 |
public static Level toLevel(int val, Level defaultLevel)... |
131 |
|
{ |
132 |
0 |
switch (val) |
133 |
|
{ |
134 |
0 |
case ALL_INT: |
135 |
0 |
return ALL; |
136 |
0 |
case DEBUG_INT: |
137 |
0 |
return Level.DEBUG; |
138 |
0 |
case INFO_INT: |
139 |
0 |
return Level.INFO; |
140 |
0 |
case WARN_INT: |
141 |
0 |
return Level.WARN; |
142 |
0 |
case ERROR_INT: |
143 |
0 |
return Level.ERROR; |
144 |
0 |
case FATAL_INT: |
145 |
0 |
return Level.FATAL; |
146 |
0 |
case OFF_INT: |
147 |
0 |
return OFF; |
148 |
0 |
case TRACE_INT: |
149 |
0 |
return Level.TRACE; |
150 |
0 |
default: |
151 |
0 |
return defaultLevel; |
152 |
|
} |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 11 |
Complexity Density: 0.5 |
|
159 |
0 |
public static Level toLevel(String sArg, Level defaultLevel)... |
160 |
|
{ |
161 |
0 |
if (sArg == null) |
162 |
|
{ |
163 |
0 |
return defaultLevel; |
164 |
|
} |
165 |
0 |
String s = sArg.toUpperCase(); |
166 |
|
|
167 |
0 |
if (s.equals(ALL_NAME)) |
168 |
|
{ |
169 |
0 |
return Level.ALL; |
170 |
|
} |
171 |
0 |
if (s.equals(DEBUG_NAME)) |
172 |
|
{ |
173 |
0 |
return Level.DEBUG; |
174 |
|
} |
175 |
0 |
if (s.equals(INFO_NAME)) |
176 |
|
{ |
177 |
0 |
return Level.INFO; |
178 |
|
} |
179 |
0 |
if (s.equals(WARN_NAME)) |
180 |
|
{ |
181 |
0 |
return Level.WARN; |
182 |
|
} |
183 |
0 |
if (s.equals(ERROR_NAME)) |
184 |
|
{ |
185 |
0 |
return Level.ERROR; |
186 |
|
} |
187 |
0 |
if (s.equals(FATAL_NAME)) |
188 |
|
{ |
189 |
0 |
return Level.FATAL; |
190 |
|
} |
191 |
0 |
if (s.equals(OFF_NAME)) |
192 |
|
{ |
193 |
0 |
return Level.OFF; |
194 |
|
} |
195 |
0 |
if (s.equals(TRACE_NAME)) |
196 |
|
{ |
197 |
0 |
return Level.TRACE; |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
0 |
if (s.equals("\u0130NFO")) |
203 |
|
{ |
204 |
0 |
return Level.INFO; |
205 |
|
} |
206 |
0 |
return defaultLevel; |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
@param |
213 |
|
|
214 |
|
@throws |
215 |
|
|
216 |
|
@throws |
217 |
|
|
218 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
219 |
0 |
private void readObject(final ObjectInputStream s)... |
220 |
|
throws IOException, ClassNotFoundException |
221 |
|
{ |
222 |
0 |
s.defaultReadObject(); |
223 |
0 |
level = s.readInt(); |
224 |
0 |
syslogEquivalent = s.readInt(); |
225 |
0 |
levelStr = s.readUTF(); |
226 |
0 |
if (levelStr == null) |
227 |
|
{ |
228 |
0 |
levelStr = ""; |
229 |
|
} |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
@param |
236 |
|
|
237 |
|
@throws |
238 |
|
|
239 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
240 |
0 |
private void writeObject(final ObjectOutputStream s) throws IOException... |
241 |
|
{ |
242 |
0 |
s.defaultWriteObject(); |
243 |
0 |
s.writeInt(level); |
244 |
0 |
s.writeInt(syslogEquivalent); |
245 |
0 |
s.writeUTF(levelStr); |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
@return |
253 |
|
@throws |
254 |
|
|
255 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
256 |
0 |
private Object readResolve() throws ObjectStreamException... |
257 |
|
{ |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
0 |
if (getClass() == Level.class) |
262 |
|
{ |
263 |
0 |
return toLevel(level); |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
0 |
return this; |
269 |
|
} |
270 |
|
|
271 |
|
} |