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