1 2 17 18 19 package org.apache.poi.util; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 import java.util.*; 25 26 36 37 public class CommonsLogger extends POILogger 38 { 39 40 private static LogFactory _creator = LogFactory.getFactory(); 41 private Log log = null; 42 43 44 public void initialize(final String cat) 45 { 46 this.log = _creator.getInstance(cat); 47 } 48 49 55 56 public void log(final int level, final Object obj1) 57 { 58 if(level==FATAL) 59 { 60 if(log.isFatalEnabled()) 61 { 62 log.fatal(obj1); 63 } 64 } 65 else if(level==ERROR) 66 { 67 if(log.isErrorEnabled()) 68 { 69 log.error(obj1); 70 } 71 } 72 else if(level==WARN) 73 { 74 if(log.isWarnEnabled()) 75 { 76 log.warn(obj1); 77 } 78 } 79 else if(level==INFO) 80 { 81 if(log.isInfoEnabled()) 82 { 83 log.info(obj1); 84 } 85 } 86 else if(level==DEBUG) 87 { 88 if(log.isDebugEnabled()) 89 { 90 log.debug(obj1); 91 } 92 } 93 else 94 { 95 if(log.isTraceEnabled()) 96 { 97 log.trace(obj1); 98 } 99 } 100 101 } 102 103 108 109 public boolean check(final int level) 110 { 111 if(level==FATAL) 112 { 113 if(log.isFatalEnabled()) 114 { 115 return true; 116 } 117 } 118 else if(level==ERROR) 119 { 120 if(log.isErrorEnabled()) 121 { 122 return true; 123 } 124 } 125 else if(level==WARN) 126 { 127 if(log.isWarnEnabled()) 128 { 129 return true; 130 } 131 } 132 else if(level==INFO) 133 { 134 if(log.isInfoEnabled()) 135 { 136 return true; 137 } 138 } 139 else if(level==DEBUG) 140 { 141 if(log.isDebugEnabled()) 142 { 143 return true; 144 } 145 } 146 147 return false; 148 149 } 150 151 152 } 154 | Popular Tags |