1 7 package org.ozoneDB.util; 8 9 import org.apache.log4j.Level; 10 11 16 public class OzoneDebugLevel extends Level { 17 18 static public final int DEBUG1_INT = Level.DEBUG_INT - 100; 19 static public final int DEBUG2_INT = Level.DEBUG_INT - 200; 20 static public final int DEBUG3_INT = Level.DEBUG_INT - 300; 21 22 24 25 26 public static final String FATAL_STR = "FATAL"; 27 28 public static final String ERROR_STR = "ERROR"; 29 30 public static final String WARN_STR = "WARN"; 31 32 public static final String INFO_STR = "INFO"; 33 34 public static final String DEBUG_STR = "DEBUG"; 35 36 37 public static final String DEBUG1_STR = "DEBUG1"; 38 39 public static final String DEBUG2_STR = "DEBUG2"; 40 41 public static final String DEBUG3_STR = "DEBUG3"; 42 43 public static final OzoneDebugLevel DEBUG1 = new OzoneDebugLevel(DEBUG1_INT, DEBUG1_STR, 7); 44 public static final OzoneDebugLevel DEBUG2 = new OzoneDebugLevel(DEBUG2_INT, DEBUG2_STR, 7); 45 public static final OzoneDebugLevel DEBUG3 = new OzoneDebugLevel(DEBUG3_INT, DEBUG3_STR, 7); 46 47 48 protected OzoneDebugLevel(int level, String strLevel, int syslogEquiv) { 49 super(level, strLevel, syslogEquiv); 50 } 51 52 56 public static Level toLevel(String sArg) { 57 return (Level) toLevel(sArg, OzoneDebugLevel.DEBUG1); 58 } 59 60 61 public static 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(DEBUG1_STR)) { 69 return OzoneDebugLevel.DEBUG1; 70 } else if (stringVal.equals(DEBUG2_STR)) { 71 return OzoneDebugLevel.DEBUG2; 72 } else if (stringVal.equals(DEBUG3_STR)) { 73 return OzoneDebugLevel.DEBUG3; 74 } 75 76 return Level.toLevel(sArg, (Level) defaultValue); 77 } 78 79 80 public static Level toLevel(int i) throws IllegalArgumentException { 81 switch (i) { 82 case DEBUG1_INT: 83 return OzoneDebugLevel.DEBUG1; 84 case DEBUG2_INT: 85 return OzoneDebugLevel.DEBUG2; 86 case DEBUG3_INT: 87 return OzoneDebugLevel.DEBUG3; 88 } 89 return Level.toLevel(i); 90 } 91 92 } 93 | Popular Tags |