Coverage Report - org.codehaus.plexus.logging.console.ConsoleLogger
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleLogger
96 %
32/33
80 %
16/20
2,429
 
 1  
 package org.codehaus.plexus.logging.console;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2006 Codehaus Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.codehaus.plexus.logging.AbstractLogger;
 20  
 import org.codehaus.plexus.logging.Logger;
 21  
 
 22  
 /**
 23  
  * Logger sending everything to the standard output streams.
 24  
  * This is mainly for the cases when you have a utility that
 25  
  * does not have a logger to supply.
 26  
  *
 27  
  * @author <a href="mailto:dev@avalon.codehaus.org">Avalon Development Team</a>
 28  
  * @version $Id$
 29  
  */
 30  
 public final class ConsoleLogger
 31  
     extends AbstractLogger
 32  
 {
 33  
     public ConsoleLogger( int threshold, String name )
 34  
     {
 35  84
         super( threshold, name );
 36  84
     }
 37  
 
 38  
     public void debug( String message, Throwable throwable )
 39  
     {
 40  62
         if ( isDebugEnabled() )
 41  
         {
 42  2
             System.out.print( "[DEBUG] " );
 43  2
             System.out.println( message );
 44  
 
 45  2
             if ( null != throwable )
 46  
             {
 47  1
                 throwable.printStackTrace( System.out );
 48  
             }
 49  
         }
 50  62
     }
 51  
 
 52  
     public void info( String message, Throwable throwable )
 53  
     {
 54  3
         if ( isInfoEnabled() )
 55  
         {
 56  3
             System.out.print( "[INFO] " );
 57  3
             System.out.println( message );
 58  
 
 59  3
             if ( null != throwable )
 60  
             {
 61  1
                 throwable.printStackTrace( System.out );
 62  
             }
 63  
         }
 64  3
     }
 65  
 
 66  
     public void warn( String message, Throwable throwable )
 67  
     {
 68  2
         if ( isWarnEnabled() )
 69  
         {
 70  2
             System.out.print( "[WARNING] " );
 71  2
             System.out.println( message );
 72  
 
 73  2
             if ( null != throwable )
 74  
             {
 75  1
                 throwable.printStackTrace( System.out );
 76  
             }
 77  
         }
 78  2
     }
 79  
 
 80  
     public void error( String message, Throwable throwable )
 81  
     {
 82  2
         if ( isErrorEnabled() )
 83  
         {
 84  2
             System.out.print( "[ERROR] " );
 85  2
             System.out.println( message );
 86  
 
 87  2
             if ( null != throwable )
 88  
             {
 89  1
                 throwable.printStackTrace( System.out );
 90  
             }
 91  
         }
 92  2
     }
 93  
 
 94  
     public void fatalError( String message, Throwable throwable )
 95  
     {
 96  2
         if ( isFatalErrorEnabled() )
 97  
         {
 98  2
             System.out.print( "[FATAL ERROR] " );
 99  2
             System.out.println( message );
 100  
 
 101  2
             if ( null != throwable )
 102  
             {
 103  1
                 throwable.printStackTrace( System.out );
 104  
             }
 105  
         }
 106  2
     }
 107  
 
 108  
     public Logger getChildLogger( String name )
 109  
     {
 110  0
         return this;
 111  
     }
 112  
 }