KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Copyright (C) 2001-2004 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.javaLog ;
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  * Is an implementation of the Monolog Level interface based on the common
27  * LevelImpl class. It defines static method to convert a monolog level to
28  * java.util.logging.Level .
29  *
30  * @author S.Chassande-Barrioz
31  */

32 public class LevelImpl
33     extends org.objectweb.util.monolog.wrapper.common.LevelImpl {
34     
35
36     /**
37      * Level => java.util.logging.Level
38      */

39     static public java.util.logging.Level JavaDoc convertLevel(Level l) {
40         return int2Level(l.getIntValue());
41     }
42     
43     static public java.util.logging.Level JavaDoc int2Level(int value) {
44         if ( value>=BasicLevel.FATAL ) {
45             return java.util.logging.Level.SEVERE;
46         
47         } else if ( value>=BasicLevel.ERROR ) {
48             return java.util.logging.Level.SEVERE;
49         
50         } else if ( value>=BasicLevel.WARN ) {
51             return java.util.logging.Level.WARNING;
52         
53         } else if ( value>=BasicLevel.INFO ) {
54             return java.util.logging.Level.INFO;
55         
56         } else if ( value>=BasicLevel.DEBUG ) {
57             return java.util.logging.Level.FINEST;
58
59         } else if ( value==BasicLevel.INHERIT) {
60             return null;
61
62         } else {
63             return java.util.logging.Level.FINEST;
64         }
65     }
66     
67     /**
68      * int => org.objectweb.util.monolog.api.Level
69      */

70     static public Level getLevel(int value) {
71         if ( value>=BasicLevel.FATAL ) {
72             return BasicLevel.LEVEL_FATAL;
73         
74         } else if ( value>=BasicLevel.ERROR ) {
75             return BasicLevel.LEVEL_ERROR;
76         
77         } else if ( value>=BasicLevel.WARN ) {
78             return BasicLevel.LEVEL_WARN;
79         
80         } else if ( value>=BasicLevel.INFO ) {
81             return BasicLevel.LEVEL_INFO;
82         
83         } else if ( value>=BasicLevel.DEBUG ) {
84             return BasicLevel.LEVEL_DEBUG;
85         } else {
86             return BasicLevel.LEVEL_INHERIT;
87         }
88     }
89
90     public LevelImpl(String JavaDoc n, int val) {
91         super(n, val);
92     }
93
94     public LevelImpl(String JavaDoc n, String JavaDoc val, LevelFactory lf) {
95         super(n, val, lf);
96     }
97 }
98
Popular Tags