1 package org.apache.maven.plugin.logging;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.PrintWriter;
23 import java.io.StringWriter;
24
25
26
27
28
29
30 public class SystemStreamLog
31 implements Log
32 {
33
34
35
36 public void debug( CharSequence content )
37 {
38 print( "debug", content );
39 }
40
41
42
43
44 public void debug( CharSequence content, Throwable error )
45 {
46 print( "debug", content, error );
47 }
48
49
50
51
52 public void debug( Throwable error )
53 {
54 print( "debug", error );
55 }
56
57
58
59
60 public void info( CharSequence content )
61 {
62 print( "info", content );
63 }
64
65
66
67
68 public void info( CharSequence content, Throwable error )
69 {
70 print( "info", content, error );
71 }
72
73
74
75
76 public void info( Throwable error )
77 {
78 print( "info", error );
79 }
80
81
82
83
84 public void warn( CharSequence content )
85 {
86 print( "warn", content );
87 }
88
89
90
91
92 public void warn( CharSequence content, Throwable error )
93 {
94 print( "warn", content, error );
95 }
96
97
98
99
100 public void warn( Throwable error )
101 {
102 print( "warn", error );
103 }
104
105
106
107
108 public void error( CharSequence content )
109 {
110 System.err.println( "[error] " + content.toString() );
111 }
112
113
114
115
116 public void error( CharSequence content, Throwable error )
117 {
118 StringWriter sWriter = new StringWriter();
119 PrintWriter pWriter = new PrintWriter( sWriter );
120
121 error.printStackTrace( pWriter );
122
123 System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() );
124 }
125
126
127
128
129 public void error( Throwable error )
130 {
131 StringWriter sWriter = new StringWriter();
132 PrintWriter pWriter = new PrintWriter( sWriter );
133
134 error.printStackTrace( pWriter );
135
136 System.err.println( "[error] " + sWriter.toString() );
137 }
138
139
140
141
142 public boolean isDebugEnabled()
143 {
144
145 return false;
146 }
147
148
149
150
151 public boolean isInfoEnabled()
152 {
153 return true;
154 }
155
156
157
158
159 public boolean isWarnEnabled()
160 {
161 return true;
162 }
163
164
165
166
167 public boolean isErrorEnabled()
168 {
169 return true;
170 }
171
172 private void print( String prefix, CharSequence content )
173 {
174 System.out.println( "[" + prefix + "] " + content.toString() );
175 }
176
177 private void print( String prefix, Throwable error )
178 {
179 StringWriter sWriter = new StringWriter();
180 PrintWriter pWriter = new PrintWriter( sWriter );
181
182 error.printStackTrace( pWriter );
183
184 System.out.println( "[" + prefix + "] " + sWriter.toString() );
185 }
186
187 private void print( String prefix, CharSequence content, Throwable error )
188 {
189 StringWriter sWriter = new StringWriter();
190 PrintWriter pWriter = new PrintWriter( sWriter );
191
192 error.printStackTrace( pWriter );
193
194 System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() );
195 }
196 }