1 package org.enhydra.shark.logging; 2 3 import org.apache.log4j.Logger; 4 import org.apache.log4j.PropertyConfigurator; 5 import org.enhydra.shark.api.internal.logging.LoggingManager; 6 import org.enhydra.shark.api.RootException; 7 import org.enhydra.shark.api.internal.working.CallbackUtilities; 8 9 15 public class StandardLoggingManager implements LoggingManager { 16 17 private static final String defaultLogChannel="Shark"; 18 private CallbackUtilities cus; 19 20 28 public void configure (CallbackUtilities cus) throws RootException { 29 this.cus=cus; 30 PropertyConfigurator.configure(cus.getProperties()); 31 } 32 33 37 45 public void error (String msg) throws RootException { 46 error(defaultLogChannel,msg); 47 } 48 49 58 public void error (String msg,RootException ex) throws RootException { 59 error(defaultLogChannel,msg,ex); 60 } 61 62 71 public void error (String channel,String msg) throws RootException { 72 Logger logger=Logger.getLogger(channel); 73 if (logger!=null) 74 logger.error(msg); 75 else 76 throw new RootException("Logger does not exist!"); 77 78 } 79 80 90 public void error (String channel,String msg,RootException ex) throws RootException{ 91 Logger logger=Logger.getLogger(channel); 92 if (logger!=null) 93 logger.error(msg,ex); 94 else 95 throw new RootException("Logger does not exist!"); 96 } 97 98 106 public void warn (String msg) throws RootException { 107 warn(defaultLogChannel,msg); 108 } 109 110 119 public void warn (String msg,RootException ex) throws RootException { 120 warn(defaultLogChannel,msg,ex); 121 } 122 123 132 public void warn (String channel,String msg) throws RootException { 133 Logger logger=Logger.getLogger(channel); 134 if (logger!=null) 135 logger.warn(msg); 136 else 137 throw new RootException("Logger does not exist!"); 138 } 139 140 150 public void warn (String channel,String msg,RootException ex) throws RootException { 151 Logger logger=Logger.getLogger(channel); 152 if (logger!=null) 153 logger.warn(msg,ex); 154 else 155 throw new RootException("Logger does not exist!"); 156 } 157 158 166 public void info (String msg) throws RootException { 167 info(defaultLogChannel,msg); 168 } 169 170 179 public void info (String msg,RootException ex) throws RootException { 180 info(defaultLogChannel,msg,ex); 181 } 182 183 192 public void info (String channel,String msg) throws RootException { 193 Logger logger=Logger.getLogger(channel); 194 if (logger!=null) 195 logger.info(msg); 196 else 197 throw new RootException("Logger does not exist!"); 198 } 199 200 210 public void info (String channel,String msg,RootException ex) throws RootException { 211 Logger logger=Logger.getLogger(channel); 212 if (logger!=null) 213 logger.info(msg,ex); 214 else 215 throw new RootException("Logger does not exist!"); 216 } 217 218 226 public void debug (String msg) throws RootException { 227 debug(defaultLogChannel,msg); 228 } 229 230 239 public void debug (String msg,RootException ex) throws RootException { 240 debug(defaultLogChannel,msg,ex); 241 } 242 243 252 public void debug (String channel,String msg) throws RootException { 253 Logger logger=Logger.getLogger(channel); 254 if (logger!=null) 255 logger.debug(msg); 256 else 257 throw new RootException("Logger does not exist!"); 258 } 259 260 270 public void debug (String channel,String msg,RootException ex) throws RootException { 271 Logger logger=Logger.getLogger(channel); 272 if (logger!=null) 273 logger.debug(msg,ex); 274 else 275 throw new RootException("Logger does not exist!"); 276 } 277 278 } 279 | Popular Tags |