1 package org.apache.maven.plugin.logging; 2 3 18 19 import java.io.PrintWriter ; 20 import java.io.StringWriter ; 21 22 25 public class SystemStreamLog 26 implements Log 27 { 28 29 public void debug( CharSequence content ) 30 { 31 print( "debug", content ); 32 } 33 34 public void debug( CharSequence content, Throwable error ) 35 { 36 print( "debug", content, error ); 37 } 38 39 public void debug( Throwable error ) 40 { 41 print( "debug", error ); 42 } 43 44 public void info( CharSequence content ) 45 { 46 print( "info", content ); 47 } 48 49 public void info( CharSequence content, Throwable error ) 50 { 51 print( "info", content, error ); 52 } 53 54 public void info( Throwable error ) 55 { 56 print( "info", error ); 57 } 58 59 public void warn( CharSequence content ) 60 { 61 print( "warn", content ); 62 } 63 64 public void warn( CharSequence content, Throwable error ) 65 { 66 print( "warn", content, error ); 67 } 68 69 public void warn( Throwable error ) 70 { 71 print( "warn", error ); 72 } 73 74 public void error( CharSequence content ) 75 { 76 System.err.println( "[error] " + content.toString() ); 77 } 78 79 public void error( CharSequence content, Throwable error ) 80 { 81 StringWriter sWriter = new StringWriter (); 82 PrintWriter pWriter = new PrintWriter ( sWriter ); 83 84 error.printStackTrace( pWriter ); 85 86 System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() ); 87 } 88 89 public void error( Throwable error ) 90 { 91 StringWriter sWriter = new StringWriter (); 92 PrintWriter pWriter = new PrintWriter ( sWriter ); 93 94 error.printStackTrace( pWriter ); 95 96 System.err.println( "[error] " + sWriter.toString() ); 97 } 98 99 private void print( String prefix, CharSequence content ) 100 { 101 System.out.println( "[" + prefix + "] " + content.toString() ); 102 } 103 104 private void print( String prefix, Throwable error ) 105 { 106 StringWriter sWriter = new StringWriter (); 107 PrintWriter pWriter = new PrintWriter ( sWriter ); 108 109 error.printStackTrace( pWriter ); 110 111 System.out.println( "[" + prefix + "] " + sWriter.toString() ); 112 } 113 114 private void print( String prefix, CharSequence content, Throwable error ) 115 { 116 StringWriter sWriter = new StringWriter (); 117 PrintWriter pWriter = new PrintWriter ( sWriter ); 118 119 error.printStackTrace( pWriter ); 120 121 System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() ); 122 } 123 124 public boolean isDebugEnabled() 125 { 126 return false; 128 } 129 130 public boolean isInfoEnabled() 131 { 132 return true; 133 } 134 135 public boolean isWarnEnabled() 136 { 137 return true; 138 } 139 140 public boolean isErrorEnabled() 141 { 142 return true; 143 } 144 145 } | Popular Tags |