KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > wrapper > log4j > LevelImpl


1 /**
2  * Copyright (C) 2001-2003 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * 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  */

18
19 package org.objectweb.util.monolog.wrapper.log4j;
20
21 import org.objectweb.util.monolog.api.BasicLevel;
22 import org.objectweb.util.monolog.api.Level;
23 import org.objectweb.util.monolog.api.LevelFactory;
24
25 /**
26  * This extension of the common LevelImpl provides conversion method for the
27  * monolog levels to the log4j levels.
28  *
29  * @author S.chassande-Barrioz
30  */

31 public class LevelImpl
32     extends org.objectweb.util.monolog.wrapper.common.LevelImpl {
33
34     static public org.apache.log4j.Level convertLevel(
35         org.objectweb.util.monolog.api.Level l) {
36         return org.apache.log4j.Level.toLevel(l.getIntValue());
37     }
38
39     static public Level getLevel(int value) {
40         if (value >= BasicLevel.FATAL) {
41             return BasicLevel.LEVEL_FATAL;
42         }
43         else if (value >= BasicLevel.ERROR) {
44             return BasicLevel.LEVEL_ERROR;
45         }
46         else if (value >= BasicLevel.WARN) {
47             return BasicLevel.LEVEL_WARN;
48         }
49         else if (value >= BasicLevel.INFO) {
50             return BasicLevel.LEVEL_INFO;
51         }
52         else if (value >= BasicLevel.DEBUG) {
53             return BasicLevel.LEVEL_DEBUG;
54         }
55         else {
56             return BasicLevel.LEVEL_DEBUG;
57         }
58     }
59
60     public LevelImpl(String JavaDoc name, int val) {
61         super(name, val);
62     }
63
64     public LevelImpl(String JavaDoc name, String JavaDoc val, LevelFactory lf) {
65         super(name, val, lf);
66     }
67
68 }
69
Popular Tags