1 |
|
package org.kuali.maven.mojo; |
2 |
|
|
3 |
|
import org.apache.commons.logging.Log; |
4 |
|
import org.apache.log4j.AppenderSkeleton; |
5 |
|
import org.apache.log4j.Level; |
6 |
|
import org.apache.log4j.spi.LoggingEvent; |
7 |
|
import org.apache.maven.plugin.AbstractMojo; |
8 |
|
import org.apache.maven.plugin.logging.SystemStreamLog; |
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
|
|
| 0% |
Uncovered Elements: 109 (109) |
Complexity: 44 |
Complexity Density: 0.79 |
|
15 |
|
public class MavenLogger extends AppenderSkeleton implements Log { |
16 |
|
|
17 |
|
private static org.apache.maven.plugin.logging.Log systemStreamLog = new SystemStreamLog(); |
18 |
|
private static org.apache.maven.plugin.logging.Log mavenLog = systemStreamLog; |
19 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
20 |
0
|
public MavenLogger() {... |
21 |
0
|
this(null); |
22 |
|
} |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
0
|
public MavenLogger(final String name) {... |
28 |
0
|
super(); |
29 |
|
} |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
0
|
public static void startPluginLog(final AbstractMojo mojo) {... |
35 |
0
|
mavenLog = mojo.getLog(); |
36 |
|
} |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0
|
public static void endPluginLog(final AbstractMojo mojo) {... |
42 |
0
|
mavenLog = systemStreamLog; |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
47 |
0
|
protected Throwable getThrowable(final LoggingEvent event) {... |
48 |
0
|
if (event.getThrowableInformation() == null) { |
49 |
0
|
return null; |
50 |
|
} |
51 |
0
|
return event.getThrowableInformation().getThrowable(); |
52 |
|
} |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 16 |
Complexity Density: 0.62 |
|
54 |
0
|
@Override... |
55 |
|
protected void append(final LoggingEvent event) { |
56 |
0
|
Level level = event.getLevel(); |
57 |
0
|
if (Level.DEBUG.equals(level) && !(mavenLog.isDebugEnabled())) { |
58 |
0
|
return; |
59 |
|
} |
60 |
|
|
61 |
0
|
if (Level.TRACE.equals(level) && !(mavenLog.isDebugEnabled())) { |
62 |
0
|
return; |
63 |
|
} |
64 |
|
|
65 |
0
|
String text = this.layout.format(event); |
66 |
0
|
Throwable throwable = getThrowable(event); |
67 |
0
|
if (Level.DEBUG.equals(level) || Level.TRACE.equals(level)) { |
68 |
0
|
if (throwable == null) { |
69 |
0
|
debug(text); |
70 |
|
} else { |
71 |
0
|
debug(text, throwable); |
72 |
|
} |
73 |
0
|
} else if (Level.INFO.equals(level)) { |
74 |
0
|
if (throwable == null) { |
75 |
0
|
info(text); |
76 |
|
} else { |
77 |
0
|
info(text, throwable); |
78 |
|
} |
79 |
0
|
} else if (Level.WARN.equals(level)) { |
80 |
0
|
if (throwable == null) { |
81 |
0
|
warn(text); |
82 |
|
} else { |
83 |
0
|
warn(text, throwable); |
84 |
|
} |
85 |
0
|
} else if (Level.ERROR.equals(level) || Level.FATAL.equals(level)) { |
86 |
0
|
if (throwable == null) { |
87 |
0
|
error(text); |
88 |
|
} else { |
89 |
0
|
error(text, throwable); |
90 |
|
} |
91 |
|
} else { |
92 |
0
|
if (throwable == null) { |
93 |
0
|
error(text); |
94 |
|
} else { |
95 |
0
|
error(text, throwable); |
96 |
|
} |
97 |
|
} |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
0
|
@Override... |
101 |
|
public void close() { |
102 |
0
|
mavenLog = null; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
@Override... |
106 |
|
public boolean requiresLayout() { |
107 |
0
|
return true; |
108 |
|
} |
109 |
|
|
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0
|
@Override... |
112 |
|
public boolean isDebugEnabled() { |
113 |
0
|
return mavenLog.isDebugEnabled(); |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
116 |
0
|
@Override... |
117 |
|
public boolean isErrorEnabled() { |
118 |
0
|
return mavenLog.isErrorEnabled(); |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0
|
@Override... |
122 |
|
public boolean isFatalEnabled() { |
123 |
0
|
return mavenLog.isErrorEnabled(); |
124 |
|
} |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
0
|
@Override... |
127 |
|
public boolean isInfoEnabled() { |
128 |
0
|
return mavenLog.isInfoEnabled(); |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0
|
@Override... |
132 |
|
public boolean isTraceEnabled() { |
133 |
0
|
return mavenLog.isDebugEnabled(); |
134 |
|
} |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
0
|
@Override... |
137 |
|
public boolean isWarnEnabled() { |
138 |
0
|
return mavenLog.isWarnEnabled(); |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
@Override... |
142 |
|
public void trace(final Object message) { |
143 |
0
|
mavenLog.debug(getString(message)); |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0
|
@Override... |
147 |
|
public void trace(final Object message, final Throwable t) { |
148 |
0
|
mavenLog.debug(getString(message), t); |
149 |
|
|
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0
|
@Override... |
153 |
|
public void debug(final Object message) { |
154 |
0
|
mavenLog.debug(getString(message)); |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
0
|
@Override... |
158 |
|
public void debug(final Object message, final Throwable t) { |
159 |
0
|
mavenLog.debug(getString(message), t); |
160 |
|
} |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
0
|
@Override... |
163 |
|
public void info(final Object message) { |
164 |
0
|
mavenLog.info(getString(message)); |
165 |
|
} |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0
|
@Override... |
168 |
|
public void info(final Object message, final Throwable t) { |
169 |
0
|
mavenLog.info(getString(message), t); |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0
|
@Override... |
173 |
|
public void warn(final Object message) { |
174 |
0
|
mavenLog.warn(getString(message)); |
175 |
|
} |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
0
|
@Override... |
178 |
|
public void warn(final Object message, final Throwable t) { |
179 |
0
|
mavenLog.warn(getString(message), t); |
180 |
|
} |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
182 |
0
|
@Override... |
183 |
|
public void error(final Object message) { |
184 |
0
|
mavenLog.error(getString(message)); |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0
|
@Override... |
188 |
|
public void error(final Object message, final Throwable t) { |
189 |
0
|
mavenLog.error(getString(message), t); |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0
|
@Override... |
193 |
|
public void fatal(final Object message) { |
194 |
0
|
mavenLog.error(getString(message)); |
195 |
|
} |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
0
|
@Override... |
198 |
|
public void fatal(final Object message, final Throwable t) { |
199 |
0
|
mavenLog.error(getString(message), t); |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
205 |
0
|
protected String getString(final Object message) {... |
206 |
0
|
if (message == null) { |
207 |
0
|
return null; |
208 |
|
} |
209 |
0
|
return message.toString(); |
210 |
|
} |
211 |
|
|
212 |
|
} |