Clover coverage report - DNA Site - 1.1
Coverage timestamp: Sun May 2 2004 15:33:21 BST
file stats: LOC: 230   Methods: 17
NCLOC: 88   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Log4JLogger.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * Copyright (C) The DNA Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the DNA
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.dna.impl;
 9   
 
 10   
 import org.apache.log4j.Level;
 11   
 import org.apache.log4j.Priority;
 12   
 import org.codehaus.dna.Logger;
 13   
 
 14   
 /**
 15   
  * Logging facade implmentation for Apache Log4J project.
 16   
  * The following lists the mapping between DNA log levels
 17   
  * and Log4J log levels.
 18   
  *
 19   
  * <ul>
 20   
  *   <li>trace ==&gt; debug</li>
 21   
  *   <li>debug ==&gt; debug</li>
 22   
  *   <li>info ==&gt; info</li>
 23   
  *   <li>warn ==&gt; warn</li>
 24   
  *   <li>error ==&gt; error</li>
 25   
  * </ul>
 26   
  *
 27   
  * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
 28   
  */
 29   
 public class Log4JLogger
 30   
     implements Logger
 31   
 {
 32   
     /**
 33   
      * The fully qualified name of the current class so
 34   
      * Log4J will not include it in traces.
 35   
      */
 36   
     private static final String FQCN = Log4JLogger.class.getName();
 37   
 
 38   
     /**
 39   
      * The log4j logger instance.
 40   
      */
 41   
     private final org.apache.log4j.Logger m_logger;
 42   
 
 43   
     /**
 44   
      * Create an instance of Log4J facade.
 45   
      *
 46   
      * @param logger the log4j logger
 47   
      */
 48  100
     public Log4JLogger( final org.apache.log4j.Logger logger )
 49   
     {
 50  100
         if( null == logger )
 51   
         {
 52  4
             throw new NullPointerException( "logger" );
 53   
         }
 54  96
         m_logger = logger;
 55   
     }
 56   
 
 57   
     /**
 58   
      * Log a trace message.
 59   
      *
 60   
      * @param message the message
 61   
      */
 62  8
     public void trace( final String message )
 63   
     {
 64  8
         m_logger.log( FQCN, Level.DEBUG, message, null );
 65   
     }
 66   
 
 67   
     /**
 68   
      * Log a trace message with an associated throwable.
 69   
      *
 70   
      * @param message the message
 71   
      * @param throwable the throwable
 72   
      */
 73  8
     public void trace( final String message,
 74   
                        final Throwable throwable )
 75   
     {
 76  8
         m_logger.log( FQCN, Level.DEBUG, message, throwable );
 77   
     }
 78   
 
 79   
     /**
 80   
      * Return true if a trace message will be logged.
 81   
      *
 82   
      * @return true if message will be logged
 83   
      */
 84  16
     public boolean isTraceEnabled()
 85   
     {
 86  16
         return m_logger.isDebugEnabled();
 87   
     }
 88   
 
 89   
     /**
 90   
      * Log a debug message.
 91   
      *
 92   
      * @param message the message
 93   
      */
 94  8
     public void debug( final String message )
 95   
     {
 96  8
         m_logger.log( FQCN, Level.DEBUG, message, null );
 97   
     }
 98   
 
 99   
     /**
 100   
      * Log a debug message with an associated throwable.
 101   
      *
 102   
      * @param message the message
 103   
      * @param throwable the throwable
 104   
      */
 105  8
     public void debug( final String message,
 106   
                        final Throwable throwable )
 107   
     {
 108  8
         m_logger.log( FQCN, Level.DEBUG, message, throwable );
 109   
     }
 110   
 
 111   
     /**
 112   
      * Return true if a debug message will be logged.
 113   
      *
 114   
      * @return true if message will be logged
 115   
      */
 116  16
     public boolean isDebugEnabled()
 117   
     {
 118  16
         return m_logger.isDebugEnabled();
 119   
     }
 120   
 
 121   
     /**
 122   
      * Log a info message.
 123   
      *
 124   
      * @param message the message
 125   
      */
 126  8
     public void info( final String message )
 127   
     {
 128  8
         m_logger.log( FQCN, Level.INFO, message, null );
 129   
     }
 130   
 
 131   
     /**
 132   
      * Log a info message with an associated throwable.
 133   
      *
 134   
      * @param message the message
 135   
      * @param throwable the throwable
 136   
      */
 137  8
     public void info( final String message,
 138   
                       final Throwable throwable )
 139   
     {
 140  8
         m_logger.log( FQCN, Level.INFO, message, throwable );
 141   
     }
 142   
 
 143   
     /**
 144   
      * Return true if an info message will be logged.
 145   
      *
 146   
      * @return true if message will be logged
 147   
      */
 148  16
     public boolean isInfoEnabled()
 149   
     {
 150  16
         return m_logger.isInfoEnabled();
 151   
     }
 152   
 
 153   
     /**
 154   
      * Log a warn message.
 155   
      *
 156   
      * @param message the message
 157   
      */
 158  8
     public void warn( final String message )
 159   
     {
 160  8
         m_logger.log( FQCN, Level.WARN, message, null );
 161   
     }
 162   
 
 163   
     /**
 164   
      * Log a warn message with an associated throwable.
 165   
      *
 166   
      * @param message the message
 167   
      * @param throwable the throwable
 168   
      */
 169  8
     public void warn( final String message,
 170   
                       final Throwable throwable )
 171   
     {
 172  8
         m_logger.log( FQCN, Level.WARN, message, throwable );
 173   
     }
 174   
 
 175   
     /**
 176   
      * Return true if a warn message will be logged.
 177   
      *
 178   
      * @return true if message will be logged
 179   
      */
 180  16
     public boolean isWarnEnabled()
 181   
     {
 182  16
         return m_logger.isEnabledFor( Priority.WARN );
 183   
     }
 184   
 
 185   
     /**
 186   
      * Log a error message.
 187   
      *
 188   
      * @param message the message
 189   
      */
 190  4
     public void error( final String message )
 191   
     {
 192  4
         m_logger.log( FQCN, Level.ERROR, message, null );
 193   
     }
 194   
 
 195   
     /**
 196   
      * Log a error message with an associated throwable.
 197   
      *
 198   
      * @param message the message
 199   
      * @param throwable the throwable
 200   
      */
 201  4
     public void error( final String message,
 202   
                        final Throwable throwable )
 203   
     {
 204  4
         m_logger.log( FQCN, Level.ERROR, message, throwable );
 205   
     }
 206   
 
 207   
     /**
 208   
      * Return true if a error message will be logged.
 209   
      *
 210   
      * @return true if message will be logged
 211   
      */
 212  16
     public boolean isErrorEnabled()
 213   
     {
 214  16
         return m_logger.isEnabledFor( Priority.ERROR );
 215   
     }
 216   
 
 217   
     /**
 218   
      * Get the child logger with specified name.
 219   
      *
 220   
      * @param name the name of child logger
 221   
      * @return the child logger
 222   
      */
 223  4
     public Logger getChildLogger( final String name )
 224   
     {
 225   
 
 226  4
         return new Log4JLogger( org.apache.log4j.Logger.
 227   
                                 getLogger( m_logger.getName() + "." + name ) );
 228   
     }
 229   
 }
 230