1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.jomc.logging.ri.jdk;
37
38 import java.util.logging.Level;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
64
65
66 public final class JdkLogger
67 implements
68 org.jomc.logging.Logger,
69 org.jomc.spi.Listener
70 {
71
72
73
74 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
75 public JdkLogger()
76 {
77
78 super();
79
80 }
81
82
83
84
85 public boolean isConfigEnabled()
86 {
87 return this.getLogger().isLoggable( Level.CONFIG );
88 }
89
90 public void config( final String message )
91 {
92 this.log( Level.CONFIG, message, null );
93 }
94
95 public void config( final Throwable throwable )
96 {
97 this.log( Level.CONFIG, throwable.getMessage(), throwable );
98 }
99
100 public void config( final String message, final Throwable throwable )
101 {
102 this.log( Level.CONFIG, message, throwable );
103 }
104
105 public boolean isDebugEnabled()
106 {
107 return this.getLogger().isLoggable( Level.FINE );
108 }
109
110 public void debug( final String message )
111 {
112 this.log( Level.FINE, message, null );
113 }
114
115 public void debug( final Throwable throwable )
116 {
117 this.log( Level.FINE, throwable.getMessage(), throwable );
118 }
119
120 public void debug( final String message, final Throwable throwable )
121 {
122 this.log( Level.FINE, message, throwable );
123 }
124
125 public boolean isErrorEnabled()
126 {
127 return this.getLogger().isLoggable( Level.SEVERE );
128 }
129
130 public void error( final String message )
131 {
132 this.log( Level.SEVERE, message, null );
133 }
134
135 public void error( final Throwable throwable )
136 {
137 this.log( Level.SEVERE, throwable.getMessage(), throwable );
138 }
139
140 public void error( final String message, final Throwable throwable )
141 {
142 this.log( Level.SEVERE, message, throwable );
143 }
144
145 public boolean isFatalEnabled()
146 {
147 return this.getLogger().isLoggable( Level.SEVERE );
148 }
149
150 public void fatal( final String message )
151 {
152 this.log( Level.SEVERE, message, null );
153 }
154
155 public void fatal( final Throwable throwable )
156 {
157 this.log( Level.SEVERE, throwable.getMessage(), throwable );
158 }
159
160 public void fatal( final String message, final Throwable throwable )
161 {
162 this.log( Level.SEVERE, message, throwable );
163 }
164
165 public boolean isInfoEnabled()
166 {
167 return this.getLogger().isLoggable( Level.INFO );
168 }
169
170 public void info( final String message )
171 {
172 this.log( Level.INFO, message, null );
173 }
174
175 public void info( final Throwable throwable )
176 {
177 this.log( Level.INFO, throwable.getMessage(), throwable );
178 }
179
180 public void info( final String message, final Throwable throwable )
181 {
182 this.log( Level.INFO, message, throwable );
183 }
184
185 public boolean isTraceEnabled()
186 {
187 return this.getLogger().isLoggable( Level.FINEST );
188 }
189
190 public void trace( final String message )
191 {
192 this.log( Level.FINEST, message, null );
193 }
194
195 public void trace( final Throwable throwable )
196 {
197 this.log( Level.FINEST, throwable.getMessage(), throwable );
198 }
199
200 public void trace( final String message, final Throwable throwable )
201 {
202 this.log( Level.FINEST, message, throwable );
203 }
204
205 public boolean isWarnEnabled()
206 {
207 return this.getLogger().isLoggable( Level.WARNING );
208 }
209
210 public void warn( final String message )
211 {
212 this.log( Level.WARNING, message, null );
213 }
214
215 public void warn( final Throwable throwable )
216 {
217 this.log( Level.WARNING, throwable.getMessage(), throwable );
218 }
219
220 public void warn( final String message, final Throwable throwable )
221 {
222 this.log( Level.WARNING, message, throwable );
223 }
224
225
226
227 public void onLog( final Level level, final String message, final Throwable throwable )
228 {
229 if ( level != null )
230 {
231 if ( level.intValue() <= Level.FINEST.intValue() )
232 {
233 this.getObjectManagementLogger().trace( message, throwable );
234 }
235 else if ( level.intValue() <= Level.FINER.intValue() )
236 {
237 this.getObjectManagementLogger().debug( message, throwable );
238 }
239 else if ( level.intValue() <= Level.FINE.intValue() )
240 {
241 this.getObjectManagementLogger().debug( message, throwable );
242 }
243 else if ( level.intValue() <= Level.CONFIG.intValue() )
244 {
245 this.getObjectManagementLogger().config( message, throwable );
246 }
247 else if ( level.intValue() <= Level.INFO.intValue() )
248 {
249 this.getObjectManagementLogger().info( message, throwable );
250 }
251 else if ( level.intValue() <= Level.WARNING.intValue() )
252 {
253 this.getObjectManagementLogger().warn( message, throwable );
254 }
255 else if ( level.intValue() <= Level.SEVERE.intValue() )
256 {
257 this.getObjectManagementLogger().error( message, throwable );
258 }
259 else if ( level.intValue() < Level.OFF.intValue() )
260 {
261 this.getObjectManagementLogger().fatal( message, throwable );
262 }
263 }
264 }
265
266
267
268
269
270
271
272
273
274
275
276 public java.util.logging.Logger getLogger()
277 {
278 return java.util.logging.Logger.getLogger( this.getName() );
279 }
280
281 private void log( final Level level, final String msg, final Throwable t )
282 {
283 if ( this.getLogger().isLoggable( level ) )
284 {
285 StackTraceElement caller;
286 final Throwable x = new Throwable();
287 final StackTraceElement[] elements = x.getStackTrace();
288
289 String cname = "unknown";
290 String method = "unknown";
291
292 if ( elements != null && elements.length >= this.getStackDepth() )
293 {
294 caller = elements[this.getStackDepth()];
295 cname = caller.getClassName();
296 method = caller.getMethodName();
297 }
298
299 if ( t == null )
300 {
301 this.getLogger().logp( level, cname, method, msg );
302 }
303 else
304 {
305 this.getLogger().logp( level, cname, method, msg, t );
306 }
307 }
308 }
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344 @SuppressWarnings("unused")
345 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
346 private org.jomc.logging.Logger getObjectManagementLogger()
347 {
348 final org.jomc.logging.Logger _d = (org.jomc.logging.Logger) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ObjectManagementLogger" );
349 assert _d != null : "'ObjectManagementLogger' dependency not found.";
350 return _d;
351 }
352
353
354
355
356
357
358
359
360
361
362
363
364 @SuppressWarnings("unused")
365 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
366 public java.lang.String getName()
367 {
368 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "name" );
369 assert _p != null : "'name' property not found.";
370 return _p;
371 }
372
373
374
375
376
377
378
379
380 @SuppressWarnings("unused")
381 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
382 private int getStackDepth()
383 {
384 final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "stackDepth" );
385 assert _p != null : "'stackDepth' property not found.";
386 return _p.intValue();
387 }
388
389
390
391
392 }