1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.log4j;
20
21
22
23
24
25
26 public class Priority {
27
28 transient int level;
29 transient String levelStr;
30 transient int syslogEquivalent;
31
32 public final static int OFF_INT = Integer.MAX_VALUE;
33 public final static int FATAL_INT = 50000;
34 public final static int ERROR_INT = 40000;
35 public final static int WARN_INT = 30000;
36 public final static int INFO_INT = 20000;
37 public final static int DEBUG_INT = 10000;
38
39 public final static int ALL_INT = Integer.MIN_VALUE;
40
41
42
43
44 final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
45
46
47
48
49 final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
50
51
52
53
54 final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
55
56
57
58
59 final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
60
61
62
63
64 final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
65
66
67
68
69
70 protected Priority() {
71 level = DEBUG_INT;
72 levelStr = "DEBUG";
73 syslogEquivalent = 7;
74 }
75
76
77
78
79 protected
80 Priority(int level, String levelStr, int syslogEquivalent) {
81 this.level = level;
82 this.levelStr = levelStr;
83 this.syslogEquivalent = syslogEquivalent;
84 }
85
86
87
88
89
90 public
91 boolean equals(Object o) {
92 if(o instanceof Priority) {
93 Priority r = (Priority) o;
94 return (this.level == r.level);
95 } else {
96 return false;
97 }
98 }
99
100
101
102
103 public
104 final
105 int getSyslogEquivalent() {
106 return syslogEquivalent;
107 }
108
109
110
111
112
113
114
115
116
117
118
119
120 public
121 boolean isGreaterOrEqual(Priority r) {
122 return level >= r.level;
123 }
124
125
126
127
128
129
130
131 public
132 static
133 Priority[] getAllPossiblePriorities() {
134 return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
135 Priority.INFO, Priority.DEBUG};
136 }
137
138
139
140
141
142 final
143 public
144 String toString() {
145 return levelStr;
146 }
147
148
149
150
151 public
152 final
153 int toInt() {
154 return level;
155 }
156
157
158
159
160 public
161 static
162 Priority toPriority(String sArg) {
163 return Level.toLevel(sArg);
164 }
165
166
167
168
169 public
170 static
171 Priority toPriority(int val) {
172 return toPriority(val, Priority.DEBUG);
173 }
174
175
176
177
178 public
179 static
180 Priority toPriority(int val, Priority defaultPriority) {
181 return Level.toLevel(val, (Level) defaultPriority);
182 }
183
184
185
186
187 public
188 static
189 Priority toPriority(String sArg, Priority defaultPriority) {
190 return Level.toLevel(sArg, (Level) defaultPriority);
191 }
192 }