Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
36   163   27   3.27
18   95   0.75   11
11     2.45  
1    
 
  QedeqLog       Line # 33 36 27 96.9% 0.9692308
 
No Tests
 
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.kernel.bo.log;
17   
18    import java.util.ArrayList;
19    import java.util.List;
20   
21    import org.qedeq.base.trace.Trace;
22   
23   
24    /**
25    * This class organizes the logging.
26    *
27    * TODO 20110606 m31: this class is a singleton but it would be better if it is not
28    * to accomplish this we must put a getLogInstance method in all
29    * important BO classes.
30    *
31    * @author Michael Meyling
32    */
 
33    public final class QedeqLog implements LogListener {
34   
35    /** This class. */
36    private static final Class CLASS = QedeqLog.class;
37   
38    /** The one and only instance. */
39    private static QedeqLog instance = new QedeqLog();
40   
41    /** The loggers. */
42    private List loggers = new ArrayList();
43   
44   
45    /**
46    * Get instance of Logger.
47    *
48    * @return singleton
49    */
 
50  9017 toggle public static final QedeqLog getInstance() {
51  9017 return instance;
52    }
53   
54   
55    /**
56    * Don't use me outside of this class.
57    */
 
58  41 toggle private QedeqLog() {
59    // nothing to do
60    }
61   
62    /**
63    * Add listener.
64    *
65    * @param log Add this listener.
66    */
 
67  36 toggle public synchronized void addLog(final LogListener log) {
68  36 if (log == null) {
69  0 return;
70    }
71  36 loggers.add(log);
72  36 Trace.paramInfo(CLASS, this, "addLog(LogListener)", "log", log.getClass());
73    }
74   
75    /**
76    * Remove listener.
77    *
78    * @param log Remove this listener.
79    */
 
80  37 toggle public synchronized void removeLog(final LogListener log) {
81  37 loggers.remove(log);
82  37 if (log != null) {
83  36 Trace.paramInfo(CLASS, this, "removeLog(LogListener)", "log", log.getClass());
84    }
85    }
86   
 
87  190 toggle public synchronized void logMessageState(final String text, final String url) {
88  373 for (int i = 0; i < loggers.size(); i++) {
89  183 try { // we don't know if the LogListener is free of programming errors...
90  183 ((LogListener) loggers.get(i)).logMessageState(text, url);
91    } catch (RuntimeException e) {
92  1 Trace.fatal(CLASS, this, "logMessageState", "LogListener throwed RuntimeException",
93    e);
94    }
95    }
96    }
97   
 
98  33 toggle public synchronized void logFailureState(final String text, final String url, final String description) {
99  50 for (int i = 0; i < loggers.size(); i++) {
100  17 try { // we don't know if the LogListener is free of programming errors...
101  17 ((LogListener) loggers.get(i)).logFailureState(text, url, description);
102    } catch (RuntimeException e) {
103  1 Trace.fatal(CLASS, this, "logFailureState", "LogListener throwed RuntimeException",
104    e);
105    }
106    }
107    }
108   
 
109  49 toggle public synchronized void logSuccessfulState(final String text, final String url) {
110  99 for (int i = 0; i < loggers.size(); i++) {
111  50 try { // we don't know if the LogListener is free of programming errors...
112  50 ((LogListener) loggers.get(i)).logSuccessfulState(text, url);
113    } catch (RuntimeException e) {
114  1 Trace.fatal(CLASS, this, "logSuccessfulState",
115    "LogListener throwed RuntimeException", e);
116    }
117    }
118    }
119   
 
120  1133 toggle public synchronized void logRequest(final String text, final String url) {
121  1156 for (int i = 0; i < loggers.size(); i++) {
122  23 try { // we don't know if the LogListener is free of programming errors...
123  23 ((LogListener) loggers.get(i)).logRequest(text, url);
124    } catch (RuntimeException e) {
125  1 Trace.fatal(CLASS, this, "logRequest", "LogListener throwed RuntimeException", e);
126    }
127    }
128    }
129   
 
130  1028 toggle public synchronized void logSuccessfulReply(final String text, final String url) {
131  1048 for (int i = 0; i < loggers.size(); i++) {
132  20 try { // we don't know if the LogListener is free of programming errors...
133  20 ((LogListener) loggers.get(i)).logSuccessfulReply(text, url);
134    } catch (RuntimeException e) {
135  1 Trace.fatal(CLASS, this, "logSuccessfulReply", "LogListener throwed RuntimeException",
136    e);
137    }
138    }
139    }
140   
 
141  94 toggle public synchronized void logFailureReply(final String text, final String url, final String description) {
142  102 for (int i = 0; i < loggers.size(); i++) {
143  8 try { // we don't know if the LogListener is free of programming errors...
144  8 ((LogListener) loggers.get(i)).logFailureReply(text, url, description);
145    } catch (RuntimeException e) {
146  2 Trace.fatal(CLASS, this, "logFailureReply", "LogListener throwed RuntimeException",
147    e);
148    }
149    }
150    }
151   
 
152  6463 toggle public synchronized void logMessage(final String text) {
153  6489 for (int i = 0; i < loggers.size(); i++) {
154  26 try { // we don't know if the LogListener is free of programming errors...
155  26 ((LogListener) loggers.get(i)).logMessage(text);
156    } catch (RuntimeException e) {
157  3 Trace.fatal(CLASS, this, "logMessage", "LogListener throwed RuntimeException", e);
158    }
159    }
160    }
161   
162   
163    }