Coverage Report - org.apache.maven.plugin.logging.SystemStreamLog
 
Classes in this File Line Coverage Branch Coverage Complexity
SystemStreamLog
0%
0/47
N/A
1
 
 1  
 package org.apache.maven.plugin.logging;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.PrintWriter;
 23  
 import java.io.StringWriter;
 24  
 
 25  
 /**
 26  
  * Logger with "standard" output and error output stream.
 27  
  *
 28  
  * @author jdcasey
 29  
  * @version $Id: SystemStreamLog.java 495147 2007-01-11 07:47:53Z jvanzyl $
 30  
  */
 31  0
 public class SystemStreamLog
 32  
     implements Log
 33  
 {
 34  
     /**
 35  
      * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
 36  
      */
 37  
     public void debug( CharSequence content )
 38  
     {
 39  0
         print( "debug", content );
 40  0
     }
 41  
 
 42  
     /**
 43  
      * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable)
 44  
      */
 45  
     public void debug( CharSequence content, Throwable error )
 46  
     {
 47  0
         print( "debug", content, error );
 48  0
     }
 49  
 
 50  
     /**
 51  
      * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
 52  
      */
 53  
     public void debug( Throwable error )
 54  
     {
 55  0
         print( "debug", error );
 56  0
     }
 57  
 
 58  
     /**
 59  
      * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
 60  
      */
 61  
     public void info( CharSequence content )
 62  
     {
 63  0
         print( "info", content );
 64  0
     }
 65  
 
 66  
     /**
 67  
      * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable)
 68  
      */
 69  
     public void info( CharSequence content, Throwable error )
 70  
     {
 71  0
         print( "info", content, error );
 72  0
     }
 73  
 
 74  
     /**
 75  
      * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
 76  
      */
 77  
     public void info( Throwable error )
 78  
     {
 79  0
         print( "info", error );
 80  0
     }
 81  
 
 82  
     /**
 83  
      * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
 84  
      */
 85  
     public void warn( CharSequence content )
 86  
     {
 87  0
         print( "warn", content );
 88  0
     }
 89  
 
 90  
     /**
 91  
      * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable)
 92  
      */
 93  
     public void warn( CharSequence content, Throwable error )
 94  
     {
 95  0
         print( "warn", content, error );
 96  0
     }
 97  
 
 98  
     /**
 99  
      * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
 100  
      */
 101  
     public void warn( Throwable error )
 102  
     {
 103  0
         print( "warn", error );
 104  0
     }
 105  
 
 106  
     /**
 107  
      * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
 108  
      */
 109  
     public void error( CharSequence content )
 110  
     {
 111  0
         System.err.println( "[error] " + content.toString() );
 112  0
     }
 113  
 
 114  
     /**
 115  
      * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable)
 116  
      */
 117  
     public void error( CharSequence content, Throwable error )
 118  
     {
 119  0
         StringWriter sWriter = new StringWriter();
 120  0
         PrintWriter pWriter = new PrintWriter( sWriter );
 121  
 
 122  0
         error.printStackTrace( pWriter );
 123  
 
 124  0
         System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() );
 125  0
     }
 126  
 
 127  
     /**
 128  
      * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
 129  
      */
 130  
     public void error( Throwable error )
 131  
     {
 132  0
         StringWriter sWriter = new StringWriter();
 133  0
         PrintWriter pWriter = new PrintWriter( sWriter );
 134  
 
 135  0
         error.printStackTrace( pWriter );
 136  
 
 137  0
         System.err.println( "[error] " + sWriter.toString() );
 138  0
     }
 139  
 
 140  
     /**
 141  
      * @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
 142  
      */
 143  
     public boolean isDebugEnabled()
 144  
     {
 145  
         // TODO: Not sure how best to set these for this implementation...
 146  0
         return false;
 147  
     }
 148  
 
 149  
     /**
 150  
      * @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
 151  
      */
 152  
     public boolean isInfoEnabled()
 153  
     {
 154  0
         return true;
 155  
     }
 156  
 
 157  
     /**
 158  
      * @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
 159  
      */
 160  
     public boolean isWarnEnabled()
 161  
     {
 162  0
         return true;
 163  
     }
 164  
 
 165  
     /**
 166  
      * @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
 167  
      */
 168  
     public boolean isErrorEnabled()
 169  
     {
 170  0
         return true;
 171  
     }
 172  
 
 173  
     private void print( String prefix, CharSequence content )
 174  
     {
 175  0
         System.out.println( "[" + prefix + "] " + content.toString() );
 176  0
     }
 177  
 
 178  
     private void print( String prefix, Throwable error )
 179  
     {
 180  0
         StringWriter sWriter = new StringWriter();
 181  0
         PrintWriter pWriter = new PrintWriter( sWriter );
 182  
 
 183  0
         error.printStackTrace( pWriter );
 184  
 
 185  0
         System.out.println( "[" + prefix + "] " + sWriter.toString() );
 186  0
     }
 187  
 
 188  
     private void print( String prefix, CharSequence content, Throwable error )
 189  
     {
 190  0
         StringWriter sWriter = new StringWriter();
 191  0
         PrintWriter pWriter = new PrintWriter( sWriter );
 192  
 
 193  0
         error.printStackTrace( pWriter );
 194  
 
 195  0
         System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() );
 196  0
     }
 197  
 }