01: /**
02: * Copyright (C) 2001-2003 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.util.monolog.wrapper.log4j;
18:
19: import org.objectweb.util.monolog.api.BasicLevel;
20: import org.objectweb.util.monolog.api.Level;
21: import org.objectweb.util.monolog.api.LevelFactory;
22:
23: /**
24: * This extension of the common LevelImpl provides conversion method for the
25: * monolog levels to the log4j levels.
26: *
27: * @author S.chassande-Barrioz
28: */
29: public class LevelImpl extends
30: org.objectweb.util.monolog.wrapper.common.LevelImpl {
31:
32: static public org.apache.log4j.Level convertLevel(
33: org.objectweb.util.monolog.api.Level l) {
34: return org.apache.log4j.Level.toLevel(l.getIntValue());
35: }
36:
37: static public Level getLevel(int value) {
38: if (value >= BasicLevel.FATAL) {
39: return BasicLevel.LEVEL_FATAL;
40: } else if (value >= BasicLevel.ERROR) {
41: return BasicLevel.LEVEL_ERROR;
42: } else if (value >= BasicLevel.WARN) {
43: return BasicLevel.LEVEL_WARN;
44: } else if (value >= BasicLevel.INFO) {
45: return BasicLevel.LEVEL_INFO;
46: } else if (value >= BasicLevel.DEBUG) {
47: return BasicLevel.LEVEL_DEBUG;
48: } else {
49: return BasicLevel.LEVEL_DEBUG;
50: }
51: }
52:
53: public LevelImpl(String name, int val) {
54: super (name, val);
55: }
56:
57: public LevelImpl(String name, String val, LevelFactory lf) {
58: super(name, val, lf);
59: }
60:
61: }
|