Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
128   608   92   3.66
110   289   0.72   35
35     2.63  
1    
 
  Trace       Line # 27 128 92 92.7% 0.92673993
 
  (611)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.base.trace;
17   
18    import org.apache.commons.logging.Log;
19    import org.apache.commons.logging.LogFactory;
20   
21   
22    /**
23    * Developer trace.
24    *
25    * @author Michael Meyling
26    */
 
27    public final class Trace {
28   
29    /** Logger for business messages. */
30    private static final Log BUSINESS = LogFactory.getFactory().getInstance("log");
31   
32    /** Is tracing on? If not only fatal errors and business messages are logged. */
33    private static boolean traceOn = false;
34   
35    /**
36    * Constructor.
37    */
 
38  0 toggle private Trace() {
39    // don't call me
40    }
41   
42    /**
43    * Set tracing on. If not set only fatal errors and business messages are logged.
44    *
45    * @param on Set tracing on?
46    */
 
47  1049 toggle public static void setTraceOn(final boolean on) {
48  1049 traceOn = on;
49    }
50   
51    /**
52    * Is tracing on? If not set only fatal errors and business messages are logged.
53    *
54    * @return Is tracing on?
55    */
 
56  11234 toggle public static boolean isTraceOn() {
57  11234 return traceOn;
58    }
59   
60    /**
61    * Trace business log message. The message is logged on "error" level.
62    *
63    * @param message Business log message.
64    */
 
65  16 toggle public static void log(final String message) {
66  16 BUSINESS.error(message);
67    }
68   
69    /**
70    * Trace business log message. The message is logged on "error" level.
71    *
72    * @param message Business log message.
73    * @param additional Extra info for the next line.
74    */
 
75  4 toggle public static void log(final String message, final String additional) {
76  4 if (BUSINESS.isErrorEnabled()) {
77  4 BUSINESS.error(message);
78  4 BUSINESS.error(" " + additional);
79    }
80    }
81   
82    /**
83    * Trace business log message. The message is logged on "error" level.
84    *
85    * @param message Business log message.
86    * @param additional Extra info for the next line.
87    * @param description Further description.
88    */
 
89  0 toggle public static void log(final String message, final String additional, final String description) {
90  0 if (BUSINESS.isErrorEnabled()) {
91  0 BUSINESS.error(message);
92  0 BUSINESS.error(" " + additional);
93  0 BUSINESS.error(" " + description);
94    }
95    }
96   
97    /**
98    * Is debug log currently enabled?
99    *
100    * @param tracingClass Class we want to know the debug logging status for.
101    * @return Debug log enabled.
102    */
 
103  3715030 toggle public static boolean isDebugEnabled(final Class tracingClass) {
104  3715030 if (traceOn) {
105  0 final Log log = LogFactory.getFactory().getInstance(tracingClass);
106  0 return log.isDebugEnabled();
107    }
108  3715030 return false;
109    }
110   
111    /**
112    * Trace object.
113    * @param tracingClass Class that wants to make a trace entry.
114    * @param tracingObject Instance that wants to make a trace entry.
115    * @param method Method of that object.
116    * @param object Object to trace.
117    */
 
118  19056028 toggle public static void trace(final Class tracingClass, final Object tracingObject,
119    final String method, final Object object) {
120  19056028 if (traceOn) {
121  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
122  5 if (log.isDebugEnabled()) {
123  2 log.debug("." + method + " " + object);
124    }
125    }
126    }
127   
128    /**
129    * Trace object.
130    *
131    * @param tracingClass Class that wants to make a trace entry.
132    * @param method Method of that class.
133    * @param object Object to trace.
134    */
 
135  344871 toggle public static void trace(final Class tracingClass, final String method,
136    final Object object) {
137  344871 if (traceOn) {
138  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
139  5 if (log.isDebugEnabled()) {
140  2 log.debug("." + method + " " + object);
141    }
142    }
143    }
144   
145    /**
146    * Trace throwable.
147    *
148    * @param tracingClass Class that wants to make a trace entry.
149    * @param tracingObject Instance that wants to make a trace entry.
150    * @param method Method of that object.
151    * @param throwable Throwable to trace.
152    */
 
153  326 toggle public static void trace(final Class tracingClass, final Object tracingObject,
154    final String method, final Throwable throwable) {
155  326 if (traceOn) {
156  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
157  5 if (log.isDebugEnabled()) {
158  2 log.debug("." + method + " " + throwable, throwable);
159    }
160    }
161    }
162   
163    /**
164    * Trace throwable.
165    *
166    * @param tracingClass Class that wants to make a trace entry.
167    * @param method Method of that class.
168    * @param throwable Throwable to trace.
169    */
 
170  5 toggle public static void trace(final Class tracingClass, final String method,
171    final Throwable throwable) {
172  5 if (traceOn) {
173  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
174  5 if (log.isDebugEnabled()) {
175  2 log.debug("." + method + " " + throwable, throwable);
176    }
177    }
178    }
179   
180    /**
181    * Trace fatal throwable and extra description.
182    *
183    * @param tracingClass Class that wants to make a trace entry.
184    * @param tracingObject Instance that wants to make a trace entry.
185    * @param method Method of that object.
186    * @param description Further information.
187    * @param throwable Throwable to trace.
188    */
 
189  12 toggle public static void fatal(final Class tracingClass, final Object tracingObject,
190    final String method, final String description, final Throwable throwable) {
191  12 final Log log = LogFactory.getFactory().getInstance(tracingClass);
192  12 log.fatal("." + method + " " + description, throwable);
193    }
194   
195    /**
196    * Trace fatal throwable and extra description.
197    *
198    * @param tracingClass Class that wants to make a trace entry.
199    * @param method Method of that class.
200    * @param description Further information.
201    * @param throwable Throwable to trace.
202    */
 
203  4 toggle public static void fatal(final Class tracingClass, final String method,
204    final String description, final Throwable throwable) {
205  4 final Log log = LogFactory.getFactory().getInstance(tracingClass);
206  4 log.fatal("." + method + " " + description, throwable);
207    }
208   
209    /**
210    * Trace throwable and extra description.
211    *
212    * @param tracingClass Class that wants to make a trace entry.
213    * @param tracingObject Instance that wants to make a trace entry.
214    * @param method Method of that object.
215    * @param description Further information.
216    * @param throwable Throwable to trace.
217    */
 
218  6 toggle public static void trace(final Class tracingClass, final Object tracingObject,
219    final String method, final String description, final Throwable throwable) {
220  6 if (traceOn) {
221  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
222  5 if (log.isDebugEnabled()) {
223  2 log.debug("." + method + " " + description, throwable);
224    }
225    }
226    }
227   
228    /**
229    * Trace throwable and extra description.
230    *
231    * @param tracingClass Class that wants to make a trace entry.
232    * @param method Method of that class.
233    * @param description Further information.
234    * @param throwable Throwable to trace.
235    */
 
236  6 toggle public static void trace(final Class tracingClass, final String method,
237    final String description, final Throwable throwable) {
238  6 if (traceOn) {
239  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
240  5 if (log.isDebugEnabled()) {
241  2 log.debug("." + method + " " + description, throwable);
242    }
243    }
244    }
245   
246    /**
247    * Trace method begin. Should be followed by an analogous
248    * {@link #end(Class, Object, String)} call.
249    *
250    * @param tracingClass Class that wants to make a trace entry.
251    * @param tracingObject Instance that wants to make a trace entry.
252    * @param method Method of that object.
253    */
 
254  583949 toggle public static void begin(final Class tracingClass, final Object tracingObject,
255    final String method) {
256  583949 if (traceOn) {
257  6 final Log log = LogFactory.getFactory().getInstance(tracingClass);
258  6 if (log.isDebugEnabled()) {
259  2 log.debug("." + method + " " + "begin");
260    }
261    }
262    }
263   
264    /**
265    * Trace method begin. Should be followed by an analogous {@link #end(Class, String)} call.
266    *
267    * @param tracingClass Class that wants to make a trace entry.
268    * @param method Method of that class.
269    */
 
270  309 toggle public static void begin(final Class tracingClass, final String method) {
271  309 if (traceOn) {
272  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
273  5 if (log.isDebugEnabled()) {
274  2 log.debug("." + method + " " + "begin");
275    }
276    }
277    }
278   
279    /**
280    * Trace method end.
281    *
282    * @param tracingClass Class that wants to make a trace entry.
283    * @param tracingObject Instance that wants to make a trace entry.
284    * @param method Method of that object.
285    */
 
286  583900 toggle public static void end(final Class tracingClass, final Object tracingObject,
287    final String method) {
288  583900 if (traceOn) {
289  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
290  5 if (log.isDebugEnabled()) {
291  2 log.debug("." + method + " " + "end");
292    }
293    }
294    }
295   
296    /**
297    * Trace method end.
298    *
299    * @param tracingClass Class that wants to make a trace entry.
300    * @param method Method of that class.
301    */
 
302  309 toggle public static void end(final Class tracingClass, final String method) {
303  309 if (traceOn) {
304  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
305  5 if (log.isDebugEnabled()) {
306  2 log.debug("." + method + " " + "end");
307    }
308    }
309    }
310   
311    /**
312    * Trace message.
313    *
314    * @param tracingClass Class that wants to make a trace entry.
315    * @param tracingObject Instance that wants to make a trace entry.
316    * @param method Method of that object.
317    * @param message Message.
318    */
 
319  816776 toggle public static void info(final Class tracingClass, final Object tracingObject,
320    final String method, final String message) {
321  816776 if (traceOn) {
322  3 final Log log = LogFactory.getFactory().getInstance(tracingClass);
323  3 if (log.isInfoEnabled()) {
324  2 log.info("." + method + " " + message);
325    }
326    }
327    }
328   
329    /**
330    * Trace method message.
331    *
332    * @param tracingClass Class that wants to make a trace entry.
333    * @param method Method of that class.
334    * @param message Message.
335    */
 
336  14 toggle public static void info(final Class tracingClass, final String method,
337    final String message) {
338  14 if (traceOn) {
339  3 final Log log = LogFactory.getFactory().getInstance(tracingClass);
340  3 if (log.isInfoEnabled()) {
341  2 log.info("." + method + " " + message);
342    }
343    }
344    }
345   
346    /**
347    * Trace parameter.
348    *
349    * @param tracingClass Class that wants to make a trace entry.
350    * @param tracingObject Instance that wants to make a trace entry.
351    * @param method Method of that object.
352    * @param param Parameter to trace.
353    * @param value Value of parameter.
354    */
 
355  33114161 toggle public static void param(final Class tracingClass, final Object tracingObject,
356    final String method, final String param, final Object value) {
357  33114161 if (traceOn) {
358  10 final Log log = LogFactory.getFactory().getInstance(tracingClass);
359  10 if (log.isDebugEnabled()) {
360  4 log.debug("." + method + " " + param + "=" + value);
361    }
362    }
363    }
364   
365    /**
366    * Trace parameter.
367    *
368    * @param tracingClass Class that wants to make a trace entry.
369    * @param method Method of that class.
370    * @param param Parameter to trace.
371    * @param value Value of parameter.
372    */
 
373  20542121 toggle public static void param(final Class tracingClass, final String method,
374    final String param, final Object value) {
375  20542121 if (traceOn) {
376  10 final Log log = LogFactory.getFactory().getInstance(tracingClass);
377  10 if (log.isDebugEnabled()) {
378  4 log.debug("." + method + " " + param + "=" + value);
379    }
380    }
381    }
382   
383    /**
384    * Trace parameter.
385    *
386    * @param tracingClass Class that wants to make a trace entry.
387    * @param tracingObject Instance that wants to make a trace entry.
388    * @param method Method of that object.
389    * @param param Parameter to trace.
390    * @param value Value of parameter.
391    */
 
392  1776446 toggle public static void param(final Class tracingClass, final Object tracingObject,
393    final String method, final String param, final int value) {
394  1776446 if (traceOn) {
395  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
396  5 if (log.isDebugEnabled()) {
397  2 log.debug("." + method + " " + param + "=" + value);
398    }
399    }
400    }
401   
402    /**
403    * Trace parameter.
404    *
405    * @param tracingClass Class that wants to make a trace entry.
406    * @param method Method of that class.
407    * @param param Parameter to trace.
408    * @param value Value of parameter.
409    */
 
410  5 toggle public static void param(final Class tracingClass, final String method,
411    final String param, final int value) {
412  5 if (traceOn) {
413  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
414  5 if (log.isDebugEnabled()) {
415  2 log.debug("." + method + " " + param + "=" + value);
416    }
417    }
418    }
419   
420    /**
421    * Trace parameter.
422    *
423    * @param tracingClass Class that wants to make a trace entry.
424    * @param tracingObject Instance that wants to make a trace entry.
425    * @param method Method of that object.
426    * @param param Parameter to trace.
427    * @param value Value of parameter.
428    */
 
429  5 toggle public static void param(final Class tracingClass, final Object tracingObject,
430    final String method, final String param, final boolean value) {
431  5 if (traceOn) {
432  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
433  5 if (log.isDebugEnabled()) {
434  2 log.debug("." + method + " " + param + "=" + value);
435    }
436    }
437    }
438   
439    /**
440    * Trace parameter.
441    *
442    * @param tracingClass Class that wants to make a trace entry.
443    * @param method Method of that class.
444    * @param param Parameter to trace.
445    * @param value Value of parameter.
446    */
 
447  152087 toggle public static void param(final Class tracingClass, final String method,
448    final String param, final boolean value) {
449  152087 if (traceOn) {
450  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
451  5 if (log.isDebugEnabled()) {
452  2 log.debug("." + method + " " + param + "=" + value);
453    }
454    }
455    }
456   
457    /**
458    * Write stacktrace into trace if debug level is on.
459    *
460    * @param tracingClass Class that wants to make a trace entry.
461    * @param tracingObject Instance that wants to make a trace entry.
462    * @param method Method of that object.
463    */
 
464  10 toggle public static void traceStack(final Class tracingClass, final Object tracingObject,
465    final String method) {
466  10 if (traceOn) {
467  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
468  5 if (!log.isDebugEnabled()) {
469  3 return;
470    }
471  2 try {
472  2 throw new Exception("Stacktrace");
473    } catch (Exception e) {
474  2 log.debug("." + method + " " + e, e);
475    }
476    }
477    }
478   
479    /**
480    * Write stacktrace into trace if debug level is on.
481    *
482    * @param tracingClass Class that wants to make a trace entry.
483    * @param method Method of that class.
484    */
 
485  6 toggle public static final void traceStack(final Class tracingClass, final String method) {
486  6 if (traceOn) {
487  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
488  5 if (!log.isDebugEnabled()) {
489  3 return;
490    }
491  2 try {
492  2 throw new Exception("Stacktrace");
493    } catch (Exception e) {
494  2 log.debug("." + method + " " + e, e);
495    }
496    }
497    }
498   
499    /**
500    * Parameter information.
501    *
502    * @param tracingClass Class that wants to make a trace entry.
503    * @param tracingObject Instance that wants to make an info entry.
504    * @param method Method of that object.
505    * @param param Parameter to trace.
506    * @param value Value of parameter.
507    */
 
508  1018999 toggle public static void paramInfo(final Class tracingClass, final Object tracingObject,
509    final String method, final String param, final Object value) {
510  1018999 if (traceOn) {
511  24 final Log log = LogFactory.getFactory().getInstance(tracingClass);
512  24 if (log.isInfoEnabled()) {
513  18 log.info("." + method + " " + param + "=" + value);
514    }
515    }
516    }
517   
518    /**
519    * Parameter information.
520    *
521    * @param tracingClass Class that wants to make an info entry.
522    * @param method Method of that class.
523    * @param param Parameter to trace.
524    * @param value Value of parameter.
525    */
 
526  10 toggle public static void paramInfo(final Class tracingClass, final String method,
527    final String param, final Object value) {
528  10 if (traceOn) {
529  10 final Log log = LogFactory.getFactory().getInstance(tracingClass);
530  10 if (log.isInfoEnabled()) {
531  4 log.info("." + method + " " + param + "=" + value);
532    }
533    }
534    }
535   
536    /**
537    * Parameter information.
538    * @param tracingClass Class that wants to make an info entry.
539    * @param tracingObject Instance that wants to make an info entry.
540    * @param method Method of that object.
541    * @param param Parameter to trace.
542    * @param value Value of parameter.
543    */
 
544  5 toggle public static void paramInfo(final Class tracingClass, final Object tracingObject,
545    final String method, final String param, final int value) {
546  5 if (traceOn) {
547  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
548  5 if (log.isInfoEnabled()) {
549  2 log.info("." + method + " " + param + "=" + value);
550    }
551    }
552    }
553   
554    /**
555    * Parameter information.
556    *
557    * @param tracingClass Class that wants to make an info entry.
558    * @param method Method of that class.
559    * @param param Parameter to trace.
560    * @param value Value of parameter.
561    */
 
562  5 toggle public static void paramInfo(final Class tracingClass, final String method,
563    final String param, final int value) {
564  5 if (traceOn) {
565  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
566  5 if (log.isInfoEnabled()) {
567  2 log.info("." + method + " " + param + "=" + value);
568    }
569    }
570    }
571   
572    /**
573    * Parameter information.
574    * @param tracingClass Class that wants to make an info entry.
575    * @param tracingObject Instance that wants to make an info entry.
576    * @param method Method of that object.
577    * @param param Parameter to trace.
578    * @param value Value of parameter.
579    */
 
580  5 toggle public static void paramInfo(final Class tracingClass, final Object tracingObject,
581    final String method, final String param, final boolean value) {
582  5 if (traceOn) {
583  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
584  5 if (log.isInfoEnabled()) {
585  2 log.info("." + method + " " + param + "=" + value);
586    }
587    }
588    }
589   
590    /**
591    * Parameter information.
592    *
593    * @param tracingClass Class that wants to make an info entry.
594    * @param method Method of that class.
595    * @param param Parameter to trace.
596    * @param value Value of parameter.
597    */
 
598  5 toggle public static void paramInfo(final Class tracingClass, final String method,
599    final String param, final boolean value) {
600  5 if (traceOn) {
601  5 final Log log = LogFactory.getFactory().getInstance(tracingClass);
602  5 if (log.isInfoEnabled()) {
603  2 log.info("." + method + " " + param + "=" + value);
604    }
605    }
606    }
607   
608    }