1 16 package org.apache.cocoon.portal.wsrp.logging; 17 18 import org.apache.wsrp4j.log.Logger; 19 20 28 public class WSRPLogger implements Logger { 29 30 31 protected final org.apache.avalon.framework.logger.Logger logger; 32 33 38 public WSRPLogger(org.apache.avalon.framework.logger.Logger logger) { 39 this.logger = logger; 40 } 41 42 45 public void entry(int logLevel, String loggingMethod) { 46 this.entry(logLevel, loggingMethod, null); 47 } 48 49 52 public void entry(int logLevel, String loggingMethod, Object parm1) { 53 this.entry(logLevel, loggingMethod, new Object [] { parm1 }); 54 } 55 56 59 public void entry(int logLevel, String loggingMethod, Object [] parms) { 60 this.text(logLevel, loggingMethod, "Entering method", parms); 61 } 62 63 66 public void exit(int logLevel, String loggingMethod) { 67 this.text(logLevel, loggingMethod, "Exiting method."); 68 } 69 70 73 public void exit(int logLevel, String loggingMethod, byte retValue) { 74 this.exit(logLevel, loggingMethod, new Byte (retValue)); 75 } 76 77 80 public void exit(int logLevel, String loggingMethod, short retValue) { 81 this.exit(logLevel, loggingMethod, new Short (retValue)); 82 } 83 84 87 public void exit(int logLevel, String loggingMethod, int retValue) { 88 this.exit(logLevel, loggingMethod, new Integer (retValue)); 89 } 90 91 94 public void exit(int logLevel, String loggingMethod, long retValue) { 95 this.exit(logLevel, loggingMethod, new Long (retValue)); 96 } 97 98 101 public void exit(int logLevel, String loggingMethod, float retValue) { 102 this.exit(logLevel, loggingMethod, new Float (retValue)); 103 } 104 105 108 public void exit(int logLevel, String loggingMethod, double retValue) { 109 this.exit(logLevel, loggingMethod, new Double (retValue)); 110 } 111 112 115 public void exit(int logLevel, String loggingMethod, char retValue) { 116 this.exit(logLevel, loggingMethod, new Character (retValue)); 117 } 118 119 122 public void exit(int logLevel, String loggingMethod, boolean retValue) { 123 this.exit(logLevel, loggingMethod, new Boolean (retValue)); 124 } 125 126 129 public void exit(int logLevel, String loggingMethod, Object retValue) { 130 this.text(logLevel, loggingMethod, "Exiting method. Returned value: {0}", retValue); 131 } 132 133 136 public boolean isLogging(int logLevel) { 137 if (logLevel == Logger.ERROR ) { 138 return this.logger.isErrorEnabled(); 139 } else if ( logLevel == Logger.INFO ) { 140 return this.logger.isInfoEnabled(); 141 } else if ( logLevel == Logger.WARN ) { 142 return this.logger.isWarnEnabled(); 143 } else if ( logLevel == Logger.TRACE_HIGH ) { 144 return this.logger.isInfoEnabled(); 145 } else if ( logLevel == Logger.TRACE_MEDIUM ) { 146 return this.logger.isDebugEnabled(); 147 } else if ( logLevel == Logger.TRACE_LOW ) { 148 return this.logger.isDebugEnabled(); 149 } 150 return false; 151 } 152 153 156 public void stackTrace(int logLevel, String loggingMethod, String text) { 157 this.text(logLevel, loggingMethod, new Throwable ("Stacktrace"), text); 158 } 159 160 163 public void text(int logLevel, String loggingMethod, String text) { 164 this.text(logLevel, loggingMethod, text, null); 165 } 166 167 170 public void text(int logLevel, String loggingMethod, String text, Object parm1) { 171 this.text(logLevel, loggingMethod, text, new Object [] { parm1 }); 172 } 173 174 177 public void text(int logLevel, String loggingMethod, String text, Object [] parms) { 178 this.text(logLevel, loggingMethod, (Throwable ) null, text, parms); 179 } 180 181 184 public void text(int logLevel, String loggingMethod, Throwable t, String text) { 185 this.text(logLevel, loggingMethod, t, text, null); 186 } 187 188 191 public void text(int logLevel, String loggingMethod, Throwable t, String text, Object [] parms) { 192 if (!this.isLogging(logLevel)) { 193 return; 194 } 195 StringBuffer msgBuffer = new StringBuffer (); 196 if (loggingMethod != null) { 197 msgBuffer.append(loggingMethod); 198 msgBuffer.append(" - "); 199 } 200 if (text != null) { 201 msgBuffer.append(text); 202 } 203 if (parms != null) { 204 msgBuffer.append("\nParameters:\n"); 205 for (int i = 0; i < parms.length; i++) { 206 msgBuffer.append(parms[i]); 207 } 208 } 209 210 if (logLevel == Logger.ERROR ) { 211 this.logger.error(msgBuffer.toString(), t); 212 } else if ( logLevel == Logger.INFO ) { 213 this.logger.info(msgBuffer.toString(), t); 214 } else if ( logLevel == Logger.WARN ) { 215 this.logger.warn(msgBuffer.toString(), t); 216 } else if ( logLevel == Logger.TRACE_HIGH ) { 217 this.logger.info(msgBuffer.toString(), t); 218 } else if ( logLevel == Logger.TRACE_MEDIUM ) { 219 this.logger.debug(msgBuffer.toString(), t); 220 } else if ( logLevel == Logger.TRACE_LOW ) { 221 this.logger.debug(msgBuffer.toString(), t); 222 } 223 } 224 } 225 | Popular Tags |