1 | |
package org.apache.maven.doxia.logging; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.codehaus.plexus.logging.Logger; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class PlexusLoggerWrapper |
33 | |
implements Log |
34 | |
{ |
35 | |
private final Logger logger; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public PlexusLoggerWrapper( Logger logger ) |
43 | 0 | { |
44 | 0 | this.logger = logger; |
45 | 0 | } |
46 | |
|
47 | |
|
48 | |
public void setLogLevel( int level ) |
49 | |
{ |
50 | 0 | if ( level <= LEVEL_DEBUG ) |
51 | |
{ |
52 | 0 | logger.setThreshold( Logger.LEVEL_DEBUG ); |
53 | |
} |
54 | 0 | else if ( level <= LEVEL_INFO ) |
55 | |
{ |
56 | 0 | logger.setThreshold( Logger.LEVEL_INFO ); |
57 | |
} |
58 | 0 | else if ( level <= LEVEL_WARN ) |
59 | |
{ |
60 | 0 | logger.setThreshold( Logger.LEVEL_WARN ); |
61 | |
} |
62 | 0 | else if ( level <= LEVEL_ERROR ) |
63 | |
{ |
64 | 0 | logger.setThreshold( Logger.LEVEL_ERROR ); |
65 | |
} |
66 | |
else |
67 | |
{ |
68 | 0 | logger.setThreshold( Logger.LEVEL_DISABLED ); |
69 | |
} |
70 | 0 | } |
71 | |
|
72 | |
|
73 | |
public void debug( CharSequence content ) |
74 | |
{ |
75 | 0 | logger.debug( toString( content ) ); |
76 | 0 | } |
77 | |
|
78 | |
|
79 | |
public void debug( CharSequence content, Throwable error ) |
80 | |
{ |
81 | 0 | logger.debug( toString( content ), error ); |
82 | 0 | } |
83 | |
|
84 | |
|
85 | |
public void debug( Throwable error ) |
86 | |
{ |
87 | 0 | logger.debug( "", error ); |
88 | 0 | } |
89 | |
|
90 | |
|
91 | |
public void info( CharSequence content ) |
92 | |
{ |
93 | 0 | logger.info( toString( content ) ); |
94 | 0 | } |
95 | |
|
96 | |
|
97 | |
public void info( CharSequence content, Throwable error ) |
98 | |
{ |
99 | 0 | logger.info( toString( content ), error ); |
100 | 0 | } |
101 | |
|
102 | |
|
103 | |
public void info( Throwable error ) |
104 | |
{ |
105 | 0 | logger.info( "", error ); |
106 | 0 | } |
107 | |
|
108 | |
|
109 | |
public void warn( CharSequence content ) |
110 | |
{ |
111 | 0 | logger.warn( toString( content ) ); |
112 | 0 | } |
113 | |
|
114 | |
|
115 | |
public void warn( CharSequence content, Throwable error ) |
116 | |
{ |
117 | 0 | logger.warn( toString( content ), error ); |
118 | 0 | } |
119 | |
|
120 | |
|
121 | |
public void warn( Throwable error ) |
122 | |
{ |
123 | 0 | logger.warn( "", error ); |
124 | 0 | } |
125 | |
|
126 | |
|
127 | |
public void error( CharSequence content ) |
128 | |
{ |
129 | 0 | logger.error( toString( content ) ); |
130 | 0 | } |
131 | |
|
132 | |
|
133 | |
public void error( CharSequence content, Throwable error ) |
134 | |
{ |
135 | 0 | logger.error( toString( content ), error ); |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
public void error( Throwable error ) |
140 | |
{ |
141 | 0 | logger.error( "", error ); |
142 | 0 | } |
143 | |
|
144 | |
|
145 | |
public boolean isDebugEnabled() |
146 | |
{ |
147 | 0 | return logger.isDebugEnabled(); |
148 | |
} |
149 | |
|
150 | |
|
151 | |
public boolean isInfoEnabled() |
152 | |
{ |
153 | 0 | return logger.isInfoEnabled(); |
154 | |
} |
155 | |
|
156 | |
|
157 | |
public boolean isWarnEnabled() |
158 | |
{ |
159 | 0 | return logger.isWarnEnabled(); |
160 | |
} |
161 | |
|
162 | |
|
163 | |
public boolean isErrorEnabled() |
164 | |
{ |
165 | 0 | return logger.isErrorEnabled(); |
166 | |
} |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
private String toString( CharSequence content ) |
173 | |
{ |
174 | 0 | if ( content == null ) |
175 | |
{ |
176 | 0 | return ""; |
177 | |
} |
178 | |
|
179 | 0 | return content.toString(); |
180 | |
} |
181 | |
} |