01: /**
02: * Copyright (C) 2001-2004 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.javaLog;
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: * Is an implementation of the Monolog Level interface based on the common
25: * LevelImpl class. It defines static method to convert a monolog level to
26: * java.util.logging.Level .
27: *
28: * @author S.Chassande-Barrioz
29: */
30: public class LevelImpl extends
31: org.objectweb.util.monolog.wrapper.common.LevelImpl {
32:
33: /**
34: * Level => java.util.logging.Level
35: */
36: static public java.util.logging.Level convertLevel(Level l) {
37: return int2Level(l.getIntValue());
38: }
39:
40: static public java.util.logging.Level int2Level(int value) {
41: if (value >= BasicLevel.FATAL) {
42: return java.util.logging.Level.SEVERE;
43:
44: } else if (value >= BasicLevel.ERROR) {
45: return java.util.logging.Level.SEVERE;
46:
47: } else if (value >= BasicLevel.WARN) {
48: return java.util.logging.Level.WARNING;
49:
50: } else if (value >= BasicLevel.INFO) {
51: return java.util.logging.Level.INFO;
52:
53: } else if (value >= BasicLevel.DEBUG) {
54: return java.util.logging.Level.FINEST;
55:
56: } else if (value == BasicLevel.INHERIT) {
57: return null;
58:
59: } else {
60: return java.util.logging.Level.FINEST;
61: }
62: }
63:
64: /**
65: * int => org.objectweb.util.monolog.api.Level
66: */
67: static public Level getLevel(int value) {
68: if (value >= BasicLevel.FATAL) {
69: return BasicLevel.LEVEL_FATAL;
70:
71: } else if (value >= BasicLevel.ERROR) {
72: return BasicLevel.LEVEL_ERROR;
73:
74: } else if (value >= BasicLevel.WARN) {
75: return BasicLevel.LEVEL_WARN;
76:
77: } else if (value >= BasicLevel.INFO) {
78: return BasicLevel.LEVEL_INFO;
79:
80: } else if (value >= BasicLevel.DEBUG) {
81: return BasicLevel.LEVEL_DEBUG;
82: } else {
83: return BasicLevel.LEVEL_INHERIT;
84: }
85: }
86:
87: public LevelImpl(String n, int val) {
88: super (n, val);
89: }
90:
91: public LevelImpl(String n, String val, LevelFactory lf) {
92: super(n, val, lf);
93: }
94: }
|