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.log4jMini;
18:
19: import org.apache.log4j.Priority;
20: import org.objectweb.util.monolog.api.BasicLevel;
21: import org.objectweb.util.monolog.api.Level;
22: import org.objectweb.util.monolog.api.LevelFactory;
23:
24: /**
25: * This extension of the common LevelImpl provides conversion method for the
26: * monolog levels to the log4j levels.
27: */
28: public class LevelImpl extends
29: org.objectweb.util.monolog.wrapper.common.LevelImpl {
30:
31: static public Priority convertLevel(Level l) {
32: return Priority.toPriority(l.getIntValue());
33: }
34:
35: static public Level getLevel(int value) {
36: if (value >= BasicLevel.FATAL) {
37: return BasicLevel.LEVEL_FATAL;
38: } else if (value >= BasicLevel.ERROR) {
39: return BasicLevel.LEVEL_ERROR;
40: } else if (value >= BasicLevel.WARN) {
41: return BasicLevel.LEVEL_WARN;
42: } else if (value >= BasicLevel.INFO) {
43: return BasicLevel.LEVEL_INFO;
44: } else if (value >= BasicLevel.DEBUG) {
45: return BasicLevel.LEVEL_DEBUG;
46: } else {
47: return BasicLevel.LEVEL_DEBUG;
48: }
49: }
50:
51: public LevelImpl(String name, int val) {
52: super (name, val);
53: }
54:
55: public LevelImpl(String name, String val, LevelFactory lf) {
56: super(name, val, lf);
57: }
58:
59: }
|