|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DispatchLog.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* Joey and its relative products are published under the terms
|
|
| 3 |
* of the Apache Software License.
|
|
| 4 |
*/
|
|
| 5 |
/*
|
|
| 6 |
* Created on 2004/02/02
|
|
| 7 |
*/
|
|
| 8 |
package org.asyrinx.brownie.core.log;
|
|
| 9 |
|
|
| 10 |
import org.apache.commons.logging.Log;
|
|
| 11 |
import org.apache.commons.logging.LogFactory;
|
|
| 12 |
|
|
| 13 |
/**
|
|
| 14 |
* 指定されたログレベルでログを出力するLogクラスのラッパーです。 <br>
|
|
| 15 |
* 主に、外部の設定ファイルでログレベルが指定されるような場合に 使用します。 <br>
|
|
| 16 |
* このクラスをアプリケーションから直接使用することはまずありません。 <br>
|
|
| 17 |
*
|
|
| 18 |
* @author akima
|
|
| 19 |
*/
|
|
| 20 |
public class DispatchLog implements Log { |
|
| 21 |
|
|
| 22 |
public static final String LEVEL_FATAL = "fatal"; |
|
| 23 |
|
|
| 24 |
public static final String LEVEL_ERROR = "error"; |
|
| 25 |
|
|
| 26 |
public static final String LEVEL_WARN = "warn"; |
|
| 27 |
|
|
| 28 |
public static final String LEVEL_INFO = "info"; |
|
| 29 |
|
|
| 30 |
public static final String LEVEL_DEBUG = "debug"; |
|
| 31 |
|
|
| 32 |
public static final String LEVEL_TRACE = "trace"; |
|
| 33 |
|
|
| 34 |
public static final String DEFAULT_LEVEL = LEVEL_DEBUG; |
|
| 35 |
|
|
| 36 |
/**
|
|
| 37 |
* コンストラクタ <br>
|
|
| 38 |
*
|
|
| 39 |
* @param log
|
|
| 40 |
* 実際のログ出力先となるLogオブジェクト
|
|
| 41 |
*/
|
|
| 42 | 0 |
public DispatchLog() {
|
| 43 | 0 |
this(LogFactory.getLog(DispatchLog.class), DEFAULT_LEVEL); |
| 44 |
} |
|
| 45 |
|
|
| 46 |
/**
|
|
| 47 |
* コンストラクタ <br>
|
|
| 48 |
*
|
|
| 49 |
* @param log
|
|
| 50 |
* 実際のログ出力先となるLogオブジェクト
|
|
| 51 |
*/
|
|
| 52 | 0 |
public DispatchLog(Log log) {
|
| 53 | 0 |
this(log, DEFAULT_LEVEL);
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/**
|
|
| 57 |
* コンストラクタ <br>
|
|
| 58 |
*
|
|
| 59 |
* @param log
|
|
| 60 |
* 実際のログ出力先となるLogオブジェクト
|
|
| 61 |
* @param
|
|
| 62 |
*/
|
|
| 63 | 0 |
public DispatchLog(Log log, String defaultLevel) {
|
| 64 | 0 |
super();
|
| 65 | 0 |
this.log = log;
|
| 66 | 0 |
setDefaultLevel(defaultLevel); |
| 67 |
} |
|
| 68 |
|
|
| 69 |
private Log log;
|
|
| 70 |
|
|
| 71 |
/**
|
|
| 72 |
* デフォルトログレベルのデフォルト値は"debug"です。
|
|
| 73 |
*/
|
|
| 74 |
private String defaultLevel = "debug"; |
|
| 75 |
|
|
| 76 |
/**
|
|
| 77 |
* デフォルトログレベルでログを出力します。
|
|
| 78 |
*
|
|
| 79 |
* @param message
|
|
| 80 |
* 出力メッセージ
|
|
| 81 |
* @param t
|
|
| 82 |
* 関連した例外、エラー
|
|
| 83 |
*/
|
|
| 84 | 0 |
public void log(Object message, Throwable t) { |
| 85 | 0 |
log(defaultLevel, message, t); |
| 86 |
} |
|
| 87 |
|
|
| 88 |
/**
|
|
| 89 |
* デフォルトログレベルでログを出力します。
|
|
| 90 |
*
|
|
| 91 |
* @param message
|
|
| 92 |
* 出力メッセージ
|
|
| 93 |
*/
|
|
| 94 | 0 |
public void log(Object message) { |
| 95 | 0 |
log(defaultLevel, message); |
| 96 |
} |
|
| 97 |
|
|
| 98 |
/**
|
|
| 99 |
* 指定されたログレベルでログを出力します。
|
|
| 100 |
*
|
|
| 101 |
* @param level
|
|
| 102 |
* ログレベル
|
|
| 103 |
* @param message
|
|
| 104 |
* 出力メッセージ
|
|
| 105 |
* @param t
|
|
| 106 |
* 関連した例外、エラー
|
|
| 107 |
*/
|
|
| 108 | 0 |
public void log(String level, Object message, Throwable t) { |
| 109 | 0 |
if (LEVEL_FATAL.equals(level)) {
|
| 110 | 0 |
log.fatal(message, t); |
| 111 | 0 |
} else if (LEVEL_ERROR.equals(level)) { |
| 112 | 0 |
log.error(message, t); |
| 113 | 0 |
} else if (LEVEL_WARN.equals(level)) { |
| 114 | 0 |
log.warn(message, t); |
| 115 | 0 |
} else if (LEVEL_INFO.equals(level)) { |
| 116 | 0 |
log.info(message, t); |
| 117 | 0 |
} else if (LEVEL_DEBUG.equals(level)) { |
| 118 | 0 |
log.debug(message, t); |
| 119 | 0 |
} else if (LEVEL_TRACE.equals(level)) { |
| 120 | 0 |
log.trace(message, t); |
| 121 |
} |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/**
|
|
| 125 |
* 指定されたログレベルでログを出力します。
|
|
| 126 |
*
|
|
| 127 |
* @param level
|
|
| 128 |
* ログレベル
|
|
| 129 |
* @param message
|
|
| 130 |
* 出力メッセージ
|
|
| 131 |
*/
|
|
| 132 | 0 |
public void log(String level, Object message) { |
| 133 | 0 |
if (LEVEL_FATAL.equals(level)) {
|
| 134 | 0 |
log.fatal(message); |
| 135 | 0 |
} else if (LEVEL_ERROR.equals(level)) { |
| 136 | 0 |
log.error(message); |
| 137 | 0 |
} else if (LEVEL_WARN.equals(level)) { |
| 138 | 0 |
log.warn(message); |
| 139 | 0 |
} else if (LEVEL_INFO.equals(level)) { |
| 140 | 0 |
log.info(message); |
| 141 | 0 |
} else if (LEVEL_DEBUG.equals(level)) { |
| 142 | 0 |
log.debug(message); |
| 143 | 0 |
} else if (LEVEL_TRACE.equals(level)) { |
| 144 | 0 |
log.trace(message); |
| 145 |
} |
|
| 146 |
} |
|
| 147 |
|
|
| 148 |
/**
|
|
| 149 |
* @return
|
|
| 150 |
*/
|
|
| 151 | 0 |
public Log getLog() {
|
| 152 | 0 |
return log;
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
/**
|
|
| 156 |
* @param log
|
|
| 157 |
*/
|
|
| 158 | 0 |
public void setLog(Log log) { |
| 159 | 0 |
this.log = log;
|
| 160 |
} |
|
| 161 |
|
|
| 162 |
/**
|
|
| 163 |
* デフォルトログレベルのgetterです。
|
|
| 164 |
*
|
|
| 165 |
* @return
|
|
| 166 |
*/
|
|
| 167 | 0 |
public String getDefaultLevel() {
|
| 168 | 0 |
return defaultLevel;
|
| 169 |
} |
|
| 170 |
|
|
| 171 |
/**
|
|
| 172 |
* デフォルトログレベルのsetterです。
|
|
| 173 |
*
|
|
| 174 |
* @param string
|
|
| 175 |
*/
|
|
| 176 | 0 |
public void setDefaultLevel(String string) { |
| 177 | 0 |
defaultLevel = string; |
| 178 |
} |
|
| 179 |
|
|
| 180 |
/**
|
|
| 181 |
* @param message
|
|
| 182 |
*/
|
|
| 183 | 0 |
public void debug(Object message) { |
| 184 | 0 |
log.debug(message); |
| 185 |
} |
|
| 186 |
|
|
| 187 |
/**
|
|
| 188 |
* @param message
|
|
| 189 |
* @param t
|
|
| 190 |
*/
|
|
| 191 | 0 |
public void debug(Object message, Throwable t) { |
| 192 | 0 |
log.debug(message, t); |
| 193 |
} |
|
| 194 |
|
|
| 195 |
/**
|
|
| 196 |
* @param message
|
|
| 197 |
*/
|
|
| 198 | 0 |
public void error(Object message) { |
| 199 | 0 |
log.error(message); |
| 200 |
} |
|
| 201 |
|
|
| 202 |
/**
|
|
| 203 |
* @param message
|
|
| 204 |
* @param t
|
|
| 205 |
*/
|
|
| 206 | 0 |
public void error(Object message, Throwable t) { |
| 207 | 0 |
log.error(message, t); |
| 208 |
} |
|
| 209 |
|
|
| 210 |
/**
|
|
| 211 |
* @param message
|
|
| 212 |
*/
|
|
| 213 | 0 |
public void fatal(Object message) { |
| 214 | 0 |
log.fatal(message); |
| 215 |
} |
|
| 216 |
|
|
| 217 |
/**
|
|
| 218 |
* @param message
|
|
| 219 |
* @param t
|
|
| 220 |
*/
|
|
| 221 | 0 |
public void fatal(Object message, Throwable t) { |
| 222 | 0 |
log.fatal(message, t); |
| 223 |
} |
|
| 224 |
|
|
| 225 |
/**
|
|
| 226 |
* @param message
|
|
| 227 |
*/
|
|
| 228 | 0 |
public void info(Object message) { |
| 229 | 0 |
log.info(message); |
| 230 |
} |
|
| 231 |
|
|
| 232 |
/**
|
|
| 233 |
* @param message
|
|
| 234 |
* @param t
|
|
| 235 |
*/
|
|
| 236 | 0 |
public void info(Object message, Throwable t) { |
| 237 | 0 |
log.info(message, t); |
| 238 |
} |
|
| 239 |
|
|
| 240 |
/**
|
|
| 241 |
* @return
|
|
| 242 |
*/
|
|
| 243 | 0 |
public boolean isDebugEnabled() { |
| 244 | 0 |
return log.isDebugEnabled();
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
/**
|
|
| 248 |
* @return
|
|
| 249 |
*/
|
|
| 250 | 0 |
public boolean isErrorEnabled() { |
| 251 | 0 |
return log.isErrorEnabled();
|
| 252 |
} |
|
| 253 |
|
|
| 254 |
/**
|
|
| 255 |
* @return
|
|
| 256 |
*/
|
|
| 257 | 0 |
public boolean isFatalEnabled() { |
| 258 | 0 |
return log.isFatalEnabled();
|
| 259 |
} |
|
| 260 |
|
|
| 261 |
/**
|
|
| 262 |
* @return
|
|
| 263 |
*/
|
|
| 264 | 0 |
public boolean isInfoEnabled() { |
| 265 | 0 |
return log.isInfoEnabled();
|
| 266 |
} |
|
| 267 |
|
|
| 268 |
/**
|
|
| 269 |
* @return
|
|
| 270 |
*/
|
|
| 271 | 0 |
public boolean isTraceEnabled() { |
| 272 | 0 |
return log.isTraceEnabled();
|
| 273 |
} |
|
| 274 |
|
|
| 275 |
/**
|
|
| 276 |
* @return
|
|
| 277 |
*/
|
|
| 278 | 0 |
public boolean isWarnEnabled() { |
| 279 | 0 |
return log.isWarnEnabled();
|
| 280 |
} |
|
| 281 |
|
|
| 282 |
/**
|
|
| 283 |
* @param message
|
|
| 284 |
*/
|
|
| 285 | 0 |
public void trace(Object message) { |
| 286 | 0 |
log.trace(message); |
| 287 |
} |
|
| 288 |
|
|
| 289 |
/**
|
|
| 290 |
* @param message
|
|
| 291 |
* @param t
|
|
| 292 |
*/
|
|
| 293 | 0 |
public void trace(Object message, Throwable t) { |
| 294 | 0 |
log.trace(message, t); |
| 295 |
} |
|
| 296 |
|
|
| 297 |
/**
|
|
| 298 |
* @param message
|
|
| 299 |
*/
|
|
| 300 | 0 |
public void warn(Object message) { |
| 301 | 0 |
log.warn(message); |
| 302 |
} |
|
| 303 |
|
|
| 304 |
/**
|
|
| 305 |
* @param message
|
|
| 306 |
* @param t
|
|
| 307 |
*/
|
|
| 308 | 0 |
public void warn(Object message, Throwable t) { |
| 309 | 0 |
log.warn(message, t); |
| 310 |
} |
|
| 311 |
|
|
| 312 |
} |
|
||||||||||