2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 // Contributors: Kitching Simon <Simon.Kitching@orange.ch>
20 package org.apache.log4j;
23 <font color="#AA4444">Refrain from using this class directly, use
24 the {@link Level} class instead</font>.
26 @author Ceki Gülcü */
27 public class Priority {
30 transient String levelStr;
31 transient int syslogEquivalent;
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 //public final static int FINE_INT = DEBUG_INT;
40 public final static int ALL_INT = Integer.MIN_VALUE;
43 * @deprecated Use {@link Level#FATAL} instead.
45 final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
48 * @deprecated Use {@link Level#ERROR} instead.
50 final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
53 * @deprecated Use {@link Level#WARN} instead.
55 final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
58 * @deprecated Use {@link Level#INFO} instead.
60 final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
63 * @deprecated Use {@link Level#DEBUG} instead.
65 final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
69 * Default constructor for deserialization.
71 protected Priority() {
78 Instantiate a level object.
81 Priority(int level, String levelStr, int syslogEquivalent) {
83 this.levelStr = levelStr;
84 this.syslogEquivalent = syslogEquivalent;
88 Two priorities are equal if their level fields are equal.
92 boolean equals(Object o) {
93 if(o instanceof Priority) {
94 Priority r = (Priority) o;
95 return (this.level == r.level);
102 Return the syslog equivalent of this priority as an integer.
106 int getSyslogEquivalent() {
107 return syslogEquivalent;
113 Returns <code>true</code> if this level has a higher or equal
114 level than the level passed as argument, <code>false</code>
117 <p>You should think twice before overriding the default
118 implementation of <code>isGreaterOrEqual</code> method.
122 boolean isGreaterOrEqual(Priority r) {
123 return level >= r.level;
127 Return all possible priorities as an array of Level objects in
130 @deprecated This method will be removed with no replacement.
134 Priority[] getAllPossiblePriorities() {
135 return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
136 Priority.INFO, Priority.DEBUG};
141 Returns the string representation of this priority.
150 Returns the integer representation of this level.
159 * @deprecated Please use the {@link Level#toLevel(String)} method instead.
163 Priority toPriority(String sArg) {
164 return Level.toLevel(sArg);
168 * @deprecated Please use the {@link Level#toLevel(int)} method instead.
172 Priority toPriority(int val) {
173 return toPriority(val, Priority.DEBUG);
177 * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
181 Priority toPriority(int val, Priority defaultPriority) {
182 return Level.toLevel(val, (Level) defaultPriority);
186 * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
190 Priority toPriority(String sArg, Priority defaultPriority) {
191 return Level.toLevel(sArg, (Level) defaultPriority);