1 package org.grlea.log.adapters.slf4j; 2 3 6 18 import org.grlea.log.DebugLevel; 19 import org.grlea.log.SimpleLog; 20 import org.grlea.log.SimpleLogger; 21 22 import org.slf4j.Logger; 23 import org.slf4j.LoggerFactory; 24 import org.slf4j.impl.MarkerIgnoringBase; 25 import org.slf4j.impl.MessageFormatter; 26 27 108 public class 109 Slf4jAdapter 110 extends MarkerIgnoringBase 111 { 112 113 private final SimpleLogger log; 114 115 116 private final String loggerName; 117 118 125 Slf4jAdapter(SimpleLogger log, String loggerName) 126 { 127 this.log = log; 128 this.loggerName = loggerName; 129 } 130 131 public String 132 getName() 133 { 134 return loggerName; 135 } 136 137 public boolean 138 isErrorEnabled() 139 { 140 return log.wouldLog(DebugLevel.L2_ERROR); 141 } 142 143 public boolean 144 isWarnEnabled() 145 { 146 return log.wouldLog(DebugLevel.L3_WARN); 147 } 148 149 public boolean 150 isInfoEnabled() 151 { 152 return log.wouldLog(DebugLevel.L4_INFO); 153 } 154 155 public boolean 156 isDebugEnabled() 157 { 158 return log.wouldLog(DebugLevel.L5_DEBUG); 159 } 160 161 public void 162 error(String message) 163 { 164 log.db(DebugLevel.L2_ERROR, message); 165 } 166 167 public void 168 error(String messageFormat, Object argument) 169 { 170 if (log.wouldLog(DebugLevel.L2_ERROR)) 171 { 172 log.db(DebugLevel.L2_ERROR, MessageFormatter.format(messageFormat, argument)); 173 } 174 } 175 176 public void 177 error(String messageFormat, Object argument1, Object argument2) 178 { 179 if (log.wouldLog(DebugLevel.L2_ERROR)) 180 { 181 log.db(DebugLevel.L2_ERROR, MessageFormatter.format(messageFormat, argument1, argument2)); 182 } 183 } 184 185 public void 186 error(String messageFormat, Object [] arguments) 187 { 188 if (log.wouldLog(DebugLevel.L2_ERROR)) 189 { 190 log.db(DebugLevel.L2_ERROR, MessageFormatter.format(messageFormat, arguments)); 191 } 192 } 193 194 public void 195 error(String message, Throwable exception) 196 { 197 log.db(DebugLevel.L2_ERROR, message); 198 log.dbe(DebugLevel.L2_ERROR, exception); 199 } 200 201 public void 202 warn(String message) 203 { 204 log.db(DebugLevel.L3_WARN, message); 205 } 206 207 public void 208 warn(String messageFormat, Object argument) 209 { 210 if (log.wouldLog(DebugLevel.L3_WARN)) 211 { 212 log.db(DebugLevel.L3_WARN, MessageFormatter.format(messageFormat, argument)); 213 } 214 } 215 216 public void 217 warn(String messageFormat, Object argument1, Object argument2) 218 { 219 if (log.wouldLog(DebugLevel.L3_WARN)) 220 { 221 log.db(DebugLevel.L3_WARN, MessageFormatter.format(messageFormat, argument1, argument2)); 222 } 223 } 224 225 public void 226 warn(String messageFormat, Object [] arguments) 227 { 228 if (log.wouldLog(DebugLevel.L3_WARN)) 229 { 230 log.db(DebugLevel.L3_WARN, MessageFormatter.format(messageFormat, arguments)); 231 } 232 } 233 234 public void 235 warn(String message, Throwable exception) 236 { 237 log.db(DebugLevel.L3_WARN, message); 238 log.dbe(DebugLevel.L3_WARN, exception); 239 } 240 241 public void 242 info(String message) 243 { 244 log.db(DebugLevel.L4_INFO, message); 245 } 246 247 public void 248 info(String messageFormat, Object argument) 249 { 250 if (log.wouldLog(DebugLevel.L4_INFO)) 251 { 252 log.db(DebugLevel.L4_INFO, MessageFormatter.format(messageFormat, argument)); 253 } 254 } 255 256 public void 257 info(String messageFormat, Object argument1, Object argument2) 258 { 259 if (log.wouldLog(DebugLevel.L4_INFO)) 260 { 261 log.db(DebugLevel.L4_INFO, MessageFormatter.format(messageFormat, argument1, argument2)); 262 } 263 } 264 265 public void 266 info(String messageFormat, Object [] arguments) 267 { 268 if (log.wouldLog(DebugLevel.L4_INFO)) 269 { 270 log.db(DebugLevel.L4_INFO, MessageFormatter.format(messageFormat, arguments)); 271 } 272 } 273 274 public void 275 info(String message, Throwable exception) 276 { 277 log.db(DebugLevel.L4_INFO, message); 278 log.dbe(DebugLevel.L4_INFO, exception); 279 } 280 281 public void 282 debug(String message) 283 { 284 log.db(DebugLevel.L5_DEBUG, message); 285 } 286 287 public void 288 debug(String messageFormat, Object argument) 289 { 290 if (log.wouldLog(DebugLevel.L5_DEBUG)) 291 { 292 log.db(DebugLevel.L5_DEBUG, MessageFormatter.format(messageFormat, argument)); 293 } 294 } 295 296 public void 297 debug(String messageFormat, Object argument1, Object argument2) 298 { 299 if (log.wouldLog(DebugLevel.L5_DEBUG)) 300 { 301 log.db(DebugLevel.L5_DEBUG, MessageFormatter.format(messageFormat, argument1, argument2)); 302 } 303 } 304 305 public void 306 debug(String messageFormat, Object [] arguments) 307 { 308 if (log.wouldLog(DebugLevel.L5_DEBUG)) 309 { 310 log.db(DebugLevel.L5_DEBUG, MessageFormatter.format(messageFormat, arguments)); 311 } 312 } 313 314 public void 315 debug(String message, Throwable exception) 316 { 317 log.db(DebugLevel.L5_DEBUG, message); 318 log.dbe(DebugLevel.L5_DEBUG, exception); 319 } 320 } | Popular Tags |