查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.logging;
17  
18  import java.util.logging.Level;
19  import java.util.logging.Logger;
20  
21  /**
22   * <a href="http://java.sun.com/javase/6/docs/technotes/guides/logging/index.html">java.util.logging</a>
23   * logger.
24   */
25  class JdkLogger extends AbstractInternalLogger {
26  
27      private final Logger logger;
28      private final String loggerName;
29  
30      JdkLogger(Logger logger, String loggerName) {
31          this.logger = logger;
32          this.loggerName = loggerName;
33      }
34  
35      public void debug(String msg) {
36          logger.logp(Level.FINE, loggerName, null, msg);
37      }
38  
39      public void debug(String msg, Throwable cause) {
40          logger.logp(Level.FINE, loggerName, null, msg, cause);
41      }
42  
43      public void error(String msg) {
44          logger.logp(Level.SEVERE, loggerName, null, msg);
45      }
46  
47      public void error(String msg, Throwable cause) {
48          logger.logp(Level.SEVERE, loggerName, null, msg, cause);
49      }
50  
51      public void info(String msg) {
52          logger.logp(Level.INFO, loggerName, null, msg);
53      }
54  
55      public void info(String msg, Throwable cause) {
56          logger.logp(Level.INFO, loggerName, null, msg, cause);
57      }
58  
59      public boolean isDebugEnabled() {
60          return logger.isLoggable(Level.FINE);
61      }
62  
63      public boolean isErrorEnabled() {
64          return logger.isLoggable(Level.SEVERE);
65      }
66  
67      public boolean isInfoEnabled() {
68          return logger.isLoggable(Level.INFO);
69      }
70  
71      public boolean isWarnEnabled() {
72          return logger.isLoggable(Level.WARNING);
73      }
74  
75      public void warn(String msg) {
76          logger.logp(Level.WARNING, loggerName, null, msg);
77      }
78  
79      public void warn(String msg, Throwable cause) {
80          logger.logp(Level.WARNING, loggerName, null, msg, cause);
81      }
82  
83      @Override
84      public String toString() {
85          return loggerName;
86      }
87  }