View Javadoc

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 org.apache.log4j.Logger;
19  
20  /**
21   * <a href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4J</a>
22   * logger.
23   */
24  class Log4JLogger extends AbstractInternalLogger {
25  
26      private final Logger logger;
27  
28      Log4JLogger(Logger logger) {
29          this.logger = logger;
30      }
31  
32      public void debug(String msg) {
33          logger.debug(msg);
34      }
35  
36      public void debug(String msg, Throwable cause) {
37          logger.debug(msg, cause);
38      }
39  
40      public void error(String msg) {
41          logger.error(msg);
42      }
43  
44      public void error(String msg, Throwable cause) {
45          logger.error(msg, cause);
46      }
47  
48      public void info(String msg) {
49          logger.info(msg);
50      }
51  
52      public void info(String msg, Throwable cause) {
53          logger.info(msg, cause);
54      }
55  
56      public boolean isDebugEnabled() {
57          return logger.isDebugEnabled();
58      }
59  
60      public boolean isErrorEnabled() {
61          return true;
62      }
63  
64      public boolean isInfoEnabled() {
65          return logger.isInfoEnabled();
66      }
67  
68      public boolean isWarnEnabled() {
69          return true;
70      }
71  
72      public void warn(String msg) {
73          logger.warn(msg);
74      }
75  
76      public void warn(String msg, Throwable cause) {
77          logger.warn(msg, cause);
78      }
79  
80      @Override
81      public String toString() {
82          return String.valueOf(logger.getName());
83      }
84  }