1 16 17 19 package org.apache.log4j; 20 21 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 public final static int ALL_INT = Integer.MIN_VALUE; 40 41 44 final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0); 45 46 49 final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3); 50 51 54 final static public Priority WARN = new Level(WARN_INT, "WARN", 4); 55 56 59 final static public Priority INFO = new Level(INFO_INT, "INFO", 6); 60 61 64 final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7); 65 66 67 70 protected Priority() { 71 level = DEBUG_INT; 72 levelStr = "DEBUG"; 73 syslogEquivalent = 7; 74 } 75 76 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 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 103 public 104 final 105 int getSyslogEquivalent() { 106 return syslogEquivalent; 107 } 108 109 110 111 120 public 121 boolean isGreaterOrEqual(Priority r) { 122 return level >= r.level; 123 } 124 125 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 142 final 143 public 144 String toString() { 145 return levelStr; 146 } 147 148 151 public 152 final 153 int toInt() { 154 return level; 155 } 156 157 160 public 161 static 162 Priority toPriority(String sArg) { 163 return Level.toLevel(sArg); 164 } 165 166 169 public 170 static 171 Priority toPriority(int val) { 172 return toPriority(val, Priority.DEBUG); 173 } 174 175 178 public 179 static 180 Priority toPriority(int val, Priority defaultPriority) { 181 return Level.toLevel(val, (Level) defaultPriority); 182 } 183 184 187 public 188 static 189 Priority toPriority(String sArg, Priority defaultPriority) { 190 return Level.toLevel(sArg, (Level) defaultPriority); 191 } 192 } | Popular Tags |