1 16 17 package examples.customLevel; 18 19 import org.apache.log4j.Level; 20 import org.apache.log4j.Priority; 21 22 23 28 public class XLevel extends Level { 29 30 static public final int TRACE_INT = Level.DEBUG_INT - 1; 31 static public final int LETHAL_INT = Level.FATAL_INT + 1; 32 33 34 private static String TRACE_STR = "TRACE"; 35 private static String LETHAL_STR = "LETHAL"; 36 37 38 public static final XLevel TRACE = new XLevel(TRACE_INT, TRACE_STR, 7); 39 public static final XLevel LETHAL = new XLevel(LETHAL_INT, LETHAL_STR, 40 0); 41 42 43 protected 44 XLevel(int level, String strLevel, int syslogEquiv) { 45 super(level, strLevel, syslogEquiv); 46 } 47 48 52 public 53 static 54 Level toLevel(String sArg) { 55 return (Level) toLevel(sArg, XLevel.TRACE); 56 } 57 58 59 public 60 static 61 Level toLevel(String sArg, Level defaultValue) { 62 63 if(sArg == null) { 64 return defaultValue; 65 } 66 String stringVal = sArg.toUpperCase(); 67 68 if(stringVal.equals(TRACE_STR)) { 69 return XLevel.TRACE; 70 } else if(stringVal.equals(LETHAL_STR)) { 71 return XLevel.LETHAL; 72 } 73 74 return Level.toLevel(sArg, (Level) defaultValue); 75 } 76 77 78 public 79 static 80 Level toLevel(int i) throws IllegalArgumentException { 81 switch(i) { 82 case TRACE_INT: return XLevel.TRACE; 83 case LETHAL_INT: return XLevel.LETHAL; 84 } 85 return Level.toLevel(i); 86 } 87 88 } 89 90 | Popular Tags |