1 16 package org.apache.cocoon.components.slide.impl; 17 18 import org.apache.avalon.framework.logger.Logger; 19 20 25 public class SlideLoggerAdapter implements org.apache.slide.util.logger.Logger { 26 private Logger logger; 27 private int currentLogLevel = ERROR; 28 29 public SlideLoggerAdapter(Logger logger) { 30 this.logger = logger; 31 } 32 33 public void log(Object data, Throwable t, String channel, int level) { 34 if (level==CRITICAL) { 35 this.logger.fatalError(data.toString(),t); 36 } else if (level==ERROR) { 37 this.logger.error(data.toString(),t); 38 } else if (level==WARNING) { 39 this.logger.warn(data.toString(),t); 40 } else if (level==INFO) { 41 this.logger.info(data.toString(),t); 42 } else if (level==DEBUG) { 43 this.logger.debug(data.toString(),t); 44 } else { 45 this.logger.error(data.toString(),t); 46 } 47 } 48 49 56 public void log(Object data, String channel, int level) { 57 if (level==CRITICAL) { 58 this.logger.fatalError(data.toString()); 59 } else if (level==ERROR) { 60 this.logger.error(data.toString()); 61 } else if (level==WARNING) { 62 this.logger.warn(data.toString()); 63 } else if (level==INFO) { 64 this.logger.info(data.toString()); 65 } else if (level==DEBUG) { 66 this.logger.debug(data.toString()); 67 } else { 68 this.logger.error(data.toString()); 69 } 70 } 71 72 78 public void log(Object data, int level) { 79 if (level==CRITICAL) { 80 this.logger.fatalError(data.toString()); 81 } else if (level==ERROR) { 82 this.logger.error(data.toString()); 83 } else if (level==WARNING) { 84 this.logger.warn(data.toString()); 85 } else if (level==INFO) { 86 this.logger.info(data.toString()); 87 } else if (level==DEBUG) { 88 this.logger.debug(data.toString()); 89 } else { 90 this.logger.error(data.toString()); 91 } 92 } 93 94 99 public void log(Object data) { 100 if (currentLogLevel==CRITICAL) { 101 this.logger.fatalError(data.toString()); 102 } else if (currentLogLevel==ERROR) { 103 this.logger.error(data.toString()); 104 } else if (currentLogLevel==WARNING) { 105 this.logger.warn(data.toString()); 106 } else if (currentLogLevel==INFO) { 107 this.logger.info(data.toString()); 108 } else if (currentLogLevel==DEBUG) { 109 this.logger.debug(data.toString()); 110 } else { 111 this.logger.error(data.toString()); 112 } 113 } 114 115 120 public void setLoggerLevel(int level) { 121 currentLogLevel = level; 122 } 123 124 130 public void setLoggerLevel(String channel, int level) { 131 currentLogLevel = level; 132 } 133 134 138 public int getLoggerLevel() { 139 return currentLogLevel; 140 } 141 142 148 public int getLoggerLevel(String channel) { 149 if (this.logger.isDebugEnabled()) { 150 return DEBUG; 151 } else if (this.logger.isInfoEnabled()) { 152 return INFO; 153 } else if (this.logger.isWarnEnabled()) { 154 return WARNING; 155 } else if (this.logger.isErrorEnabled()) { 156 return ERROR; 157 } else if (this.logger.isFatalErrorEnabled() ) { 158 return CRITICAL; 159 } else { 160 return ERROR; 161 } 162 } 163 164 170 public boolean isEnabled(String channel, int level) { 171 if (this.logger.isDebugEnabled()) { 172 return DEBUG<=level; 173 } else if (this.logger.isInfoEnabled()) { 174 return INFO<=level; 175 } else if (this.logger.isWarnEnabled()) { 176 return WARNING<=level; 177 } else if (this.logger.isErrorEnabled()) { 178 return ERROR<=level; 179 } else if (this.logger.isFatalErrorEnabled() ) { 180 return CRITICAL<=level; 181 } else { 182 return ERROR<=level; 183 } 184 } 185 186 191 public boolean isEnabled(int level) { 192 if (this.logger.isDebugEnabled()) { 193 return DEBUG<=level; 194 } else if (this.logger.isInfoEnabled()) { 195 return INFO<=level; 196 } else if (this.logger.isWarnEnabled()) { 197 return WARNING<=level; 198 } else if (this.logger.isErrorEnabled()) { 199 return ERROR<=level; 200 } else if (this.logger.isFatalErrorEnabled() ) { 201 return CRITICAL<=level; 202 } else { 203 return ERROR<=level; 204 } 205 } 206 207 } 208 209 | Popular Tags |