KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > logging > jdk > JDK14LoggerPlugin


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22
23 package org.jboss.logging.jdk;
24
25 import java.util.logging.Logger JavaDoc;
26 import java.util.logging.Level JavaDoc;
27
28 import org.jboss.logging.LoggerPlugin;
29
30 /** An example LoggerPlugin which uses the JDK java.util.logging framework.
31  *
32  * @author Scott.Stark@jboss.org
33  * @version $Revison:$
34  */

35 public class JDK14LoggerPlugin implements LoggerPlugin
36 {
37    private Logger JavaDoc log;
38
39    public void init(String JavaDoc name)
40    {
41       log = Logger.getLogger(name);
42    }
43
44    public boolean isTraceEnabled()
45    {
46       return log.isLoggable(Level.FINER);
47    }
48
49    public void trace(Object JavaDoc message)
50    {
51       log.finer(message.toString());
52    }
53
54    public void trace(Object JavaDoc message, Throwable JavaDoc t)
55    {
56       log.log(Level.FINER, message.toString(), t);
57    }
58
59    public boolean isDebugEnabled()
60    {
61       return log.isLoggable(Level.FINE);
62    }
63
64    public void debug(Object JavaDoc message)
65    {
66       log.fine(message.toString());
67    }
68
69    public void debug(Object JavaDoc message, Throwable JavaDoc t)
70    {
71       log.log(Level.FINE, message.toString(), t);
72    }
73
74    public boolean isInfoEnabled()
75    {
76       return log.isLoggable(Level.INFO);
77    }
78
79    public void info(Object JavaDoc message)
80    {
81       log.info(message.toString());
82    }
83
84    public void info(Object JavaDoc message, Throwable JavaDoc t)
85    {
86       log.log(Level.INFO, message.toString(), t);
87    }
88
89    public void warn(Object JavaDoc message)
90    {
91       log.warning(message.toString());
92    }
93
94    public void warn(Object JavaDoc message, Throwable JavaDoc t)
95    {
96       log.log(Level.WARNING, message.toString(), t);
97    }
98
99    public void error(Object JavaDoc message)
100    {
101       log.severe(message.toString());
102    }
103
104    public void error(Object JavaDoc message, Throwable JavaDoc t)
105    {
106       log.log(Level.SEVERE, message.toString(), t);
107    }
108
109    public void fatal(Object JavaDoc message)
110    {
111       log.severe(message.toString());
112    }
113
114    public void fatal(Object JavaDoc message, Throwable JavaDoc t)
115    {
116       log.log(Level.SEVERE, message.toString(), t);
117    }
118 }
119
Popular Tags