1 19 20 package common; 21 22 import java.security.AccessControlException ; 23 24 28 public abstract class Logger 29 { 30 33 private static Logger logger = null; 34 35 38 public static final Logger getLogger(Class cl) 39 { 40 if (logger == null) 41 { 42 initializeLogger(); 43 } 44 45 return logger.getLoggerImpl(cl); 46 } 47 48 51 private synchronized static void initializeLogger() 52 { 53 if (logger != null) 54 { 55 return; 56 } 57 58 String loggerName = common.log.LoggerName.NAME; 59 60 try 61 { 62 loggerName = System.getProperty("logger"); 64 65 if (loggerName == null) 66 { 67 loggerName = common.log.LoggerName.NAME; 69 } 70 71 logger = (Logger) Class.forName(loggerName).newInstance(); 72 } 73 catch(IllegalAccessException e) 74 { 75 logger = new common.log.SimpleLogger(); 76 logger.warn("Could not instantiate logger " + loggerName + 77 " using default"); 78 } 79 catch(InstantiationException e) 80 { 81 logger = new common.log.SimpleLogger(); 82 logger.warn("Could not instantiate logger " + loggerName + 83 " using default"); 84 } 85 catch (AccessControlException e) 86 { 87 logger = new common.log.SimpleLogger(); 88 logger.warn("Could not instantiate logger " + loggerName + 89 " using default"); 90 } 91 catch(ClassNotFoundException e) 92 { 93 logger = new common.log.SimpleLogger(); 94 logger.warn("Could not instantiate logger " + loggerName + 95 " using default"); 96 } 97 } 98 99 102 protected Logger() 103 { 104 } 105 106 109 public abstract void debug(Object message); 110 111 114 public abstract void debug(Object message, Throwable t); 115 116 119 public abstract void error(Object message); 120 121 124 public abstract void error(Object message, Throwable t); 125 126 129 public abstract void fatal(Object message); 130 131 134 public abstract void fatal(Object message, Throwable t); 135 136 139 public abstract void info(Object message); 140 141 144 public abstract void info(Object message, Throwable t); 145 146 149 public abstract void warn(Object message); 150 151 154 public abstract void warn(Object message, Throwable t); 155 156 159 protected abstract Logger getLoggerImpl(Class cl); 160 161 169 public void setSuppressWarnings(boolean w) 170 { 171 } 173 } 174 | Popular Tags |