1 23 24 package com.sun.enterprise.admin.util; 25 26 30 public class Logger 31 { 32 private final static int LOG_BASE = 13; 33 public final static int LOG_OFF = LOG_BASE; 35 public final static int LOG_ERRORS = LOG_BASE + 1; 36 public final static int LOG_DEBUG = LOG_BASE + 2; 37 38 static private Logger mInstance = new Logger(); 39 40 41 static protected int sLogLevel = LOG_DEBUG; 42 43 44 Logger() 45 { 46 } 47 48 protected void 49 _log( String msg ) 50 { 51 System.out.println( msg ); 52 } 53 54 55 57 60 public static int 61 setLogLevel( int logLevel ) 62 { 63 int oldLevel = getLogLevel(); 64 65 Assert.assertit( logLevel != LOG_OFF && 66 logLevel != LOG_ERRORS && 67 logLevel != LOG_DEBUG, "illegal log level" ); 68 69 sLogLevel = logLevel; 70 71 return( oldLevel ); 72 } 73 74 Logger 75 getInstance() 76 { 77 return( mInstance ); 78 } 79 80 public static int 81 getLogLevel() 82 { 83 return( sLogLevel ); 84 } 85 86 87 88 92 public static void 93 log( String msg ) 94 { 95 if ( sLogLevel >= LOG_DEBUG ) 96 { 97 System.out.println( msg ); 98 } 99 } 100 101 106 public static void 107 log( Object object ) 108 { 109 if ( sLogLevel >= LOG_DEBUG && object != null ) 110 { 111 log( object.toString() ); 112 } 113 } 114 115 public static void 116 logError( String msg ) 117 { 118 if ( sLogLevel >= LOG_ERRORS && msg != null ) 119 { 120 log( msg ); 121 } 122 } 123 124 public static void 125 logFatal( String msg ) 126 { 127 log( msg ); 129 } 130 }; 131 132 | Popular Tags |