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