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