KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > wrapper > log4jMini > 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.log4jMini;
20
21 import org.apache.log4j.Priority;
22 import org.objectweb.util.monolog.api.BasicLevel;
23 import org.objectweb.util.monolog.api.Level;
24 import org.objectweb.util.monolog.api.LevelFactory;
25
26 /**
27  * This extension of the common LevelImpl provides conversion method for the
28  * monolog levels to the log4j levels.
29  */

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