View Javadoc

    1   //========================================================================
    2   //$Id: Slf4jLog.java,v 1.1 2005/11/14 16:55:09 gregwilkins Exp $
    3   //Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
    4   //------------------------------------------------------------------------
    5   //Licensed under the Apache License, Version 2.0 (the "License");
    6   //you may not use this file except in compliance with the License.
    7   //You may obtain a copy of the License at
    8   //http://www.apache.org/licenses/LICENSE-2.0
    9   //Unless required by applicable law or agreed to in writing, software
    10  //distributed under the License is distributed on an "AS IS" BASIS,
    11  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //See the License for the specific language governing permissions and
    13  //limitations under the License.
    14  //========================================================================
    15
    16  package org.mortbay.log;
    17
    18
    19  public class Slf4jLog implements Logger
    20  {
    21      private org.slf4j.Logger logger;
    22
    23
    24      public Slf4jLog() throws Exception
    25      {
    26          this("org.mortbay.log");
    27      }
    28
    29      public Slf4jLog(String name)
    30      {
    31          logger = org.slf4j.LoggerFactory.getLogger( name );
    32      }
    33
    34      /* ------------------------------------------------------------ */
    35      /*
    36       * @see org.mortbay.log.Log#doDebug(java.lang.String, java.lang.Object, java.lang.Object)
    37       */
    38      public void debug(String msg, Object arg0, Object arg1)
    39      {
    40          logger.debug(msg, arg0, arg1);
    41      }
    42
    43      /* ------------------------------------------------------------ */
    44      /*
    45       * @see org.mortbay.log.Log#doDebug(java.lang.String, java.lang.Throwable)
    46       */
    47      public void debug(String msg, Throwable th)
    48      {
    49          logger.debug(msg, th);
    50      }
    51
    52      /* ------------------------------------------------------------ */
    53      /*
    54       * @see org.mortbay.log.Log#doDebugEnabled()
    55       */
    56      public boolean isDebugEnabled()
    57      {
    58          return logger.isDebugEnabled();
    59      }
    60
    61      /* ------------------------------------------------------------ */
    62      /*
    63       * @see org.mortbay.log.Log#doInfo(java.lang.String, java.lang.Object, java.lang.Object)
    64       */
    65      public void info(String msg, Object arg0, Object arg1)
    66      {
    67          logger.info(msg, arg0, arg1);
    68      }
    69
    70      /* ------------------------------------------------------------ */
    71      /*
    72       * @see org.mortbay.log.Log#doWarn(java.lang.String, java.lang.Object, java.lang.Object)
    73       */
    74      public void warn(String msg, Object arg0, Object arg1)
    75      {
    76          logger.warn(msg, arg0, arg1);
    77      }
    78
    79      /* ------------------------------------------------------------ */
    80      /*
    81       * @see org.mortbay.log.Log#doWarn(java.lang.String, java.lang.Throwable)
    82       */
    83      public void warn(String msg, Throwable th)
    84      {
    85
    86          if (th instanceof RuntimeException || th instanceof Error)
    87              logger.error(msg, th);
    88          else
    89              logger.warn(msg,th);
    90
    91      }
    92
    93      /* ------------------------------------------------------------ */
    94      public Logger getLogger(String name)
    95      {
    96          return new Slf4jLog(name);
    97
    98      }
    99
    100     /* ------------------------------------------------------------ */
    101     public String toString()
    102     {
    103         return logger.toString();
    104     }
    105
    106     /* ------------------------------------------------------------ */
    107     public void setDebugEnabled(boolean enabled)
    108     {
    109         warn("setDebugEnabled not implemented",null,null);
    110     }
    111 }