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
27
28 public class Priority {
29
30 transient int level;
31 transient String levelStr;
32 transient int syslogEquivalent;
33
34 public final static int OFF_INT = Integer.MAX_VALUE;
35 public final static int FATAL_INT = 50000;
36 public final static int ERROR_INT = 40000;
37 public final static int WARN_INT = 30000;
38 public final static int INFO_INT = 20000;
39 public final static int DEBUG_INT = 10000;
40
41 public final static int ALL_INT = Integer.MIN_VALUE;
42
43
44
45
46 final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
47
48
49
50
51 final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
52
53
54
55
56 final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
57
58
59
60
61 final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
62
63
64
65
66 final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
67
68
69
70
71 protected Priority() {
72 level = DEBUG_INT;
73 levelStr = "DEBUG";
74 syslogEquivalent = 7;
75 }
76
77
78
79
80 protected 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 boolean equals(Object o) {
91 if (o instanceof Priority) {
92 Priority r = (Priority) o;
93 return (this.level == r.level);
94 } else {
95 return false;
96 }
97 }
98
99
100
101
102 public final int getSyslogEquivalent() {
103 return syslogEquivalent;
104 }
105
106
107
108
109
110
111
112
113
114
115 public boolean isGreaterOrEqual(Priority r) {
116 return level >= r.level;
117 }
118
119
120
121
122
123
124
125 public static Priority[] getAllPossiblePriorities() {
126 return new Priority[] { Priority.FATAL, Priority.ERROR, Level.WARN, Priority.INFO, Priority.DEBUG };
127 }
128
129
130
131
132 final public String toString() {
133 return levelStr;
134 }
135
136
137
138
139 public final int toInt() {
140 return level;
141 }
142
143
144
145
146 public static Priority toPriority(String sArg) {
147 return Level.toLevel(sArg);
148 }
149
150
151
152
153 public static Priority toPriority(int val) {
154 return toPriority(val, Priority.DEBUG);
155 }
156
157
158
159
160 public static Priority toPriority(int val, Priority defaultPriority) {
161 return Level.toLevel(val, (Level) defaultPriority);
162 }
163
164
165
166
167 public static Priority toPriority(String sArg, Priority defaultPriority) {
168 return Level.toLevel(sArg, (Level) defaultPriority);
169 }
170 }