1
2
3
4
5
6
7
8
9
10
11
12
13
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
26
27
28
29
30
31
32
33 public final class QedeqLog implements LogListener {
34
35
36 private static final Class CLASS = QedeqLog.class;
37
38
39 private static QedeqLog instance = new QedeqLog();
40
41
42 private List loggers = new ArrayList();
43
44
45
46
47
48
49
50 public static final QedeqLog getInstance() {
51 return instance;
52 }
53
54
55
56
57
58 private QedeqLog() {
59
60 }
61
62
63
64
65
66
67 public synchronized void addLog(final LogListener log) {
68 if (log == null) {
69 return;
70 }
71 loggers.add(log);
72 Trace.paramInfo(CLASS, this, "addLog(LogListener)", "log", log.getClass());
73 }
74
75
76
77
78
79
80 public synchronized void removeLog(final LogListener log) {
81 loggers.remove(log);
82 if (log != null) {
83 Trace.paramInfo(CLASS, this, "removeLog(LogListener)", "log", log.getClass());
84 }
85 }
86
87 public synchronized void logMessageState(final String text, final String url) {
88 for (int i = 0; i < loggers.size(); i++) {
89 try {
90 ((LogListener) loggers.get(i)).logMessageState(text, url);
91 } catch (RuntimeException e) {
92 Trace.fatal(CLASS, this, "logMessageState", "LogListener throwed RuntimeException",
93 e);
94 }
95 }
96 }
97
98 public synchronized void logFailureState(final String text, final String url, final String description) {
99 for (int i = 0; i < loggers.size(); i++) {
100 try {
101 ((LogListener) loggers.get(i)).logFailureState(text, url, description);
102 } catch (RuntimeException e) {
103 Trace.fatal(CLASS, this, "logFailureState", "LogListener throwed RuntimeException",
104 e);
105 }
106 }
107 }
108
109 public synchronized void logSuccessfulState(final String text, final String url) {
110 for (int i = 0; i < loggers.size(); i++) {
111 try {
112 ((LogListener) loggers.get(i)).logSuccessfulState(text, url);
113 } catch (RuntimeException e) {
114 Trace.fatal(CLASS, this, "logSuccessfulState",
115 "LogListener throwed RuntimeException", e);
116 }
117 }
118 }
119
120 public synchronized void logRequest(final String text, final String url) {
121 for (int i = 0; i < loggers.size(); i++) {
122 try {
123 ((LogListener) loggers.get(i)).logRequest(text, url);
124 } catch (RuntimeException e) {
125 Trace.fatal(CLASS, this, "logRequest", "LogListener throwed RuntimeException", e);
126 }
127 }
128 }
129
130 public synchronized void logSuccessfulReply(final String text, final String url) {
131 for (int i = 0; i < loggers.size(); i++) {
132 try {
133 ((LogListener) loggers.get(i)).logSuccessfulReply(text, url);
134 } catch (RuntimeException e) {
135 Trace.fatal(CLASS, this, "logSuccessfulReply", "LogListener throwed RuntimeException",
136 e);
137 }
138 }
139 }
140
141 public synchronized void logFailureReply(final String text, final String url, final String description) {
142 for (int i = 0; i < loggers.size(); i++) {
143 try {
144 ((LogListener) loggers.get(i)).logFailureReply(text, url, description);
145 } catch (RuntimeException e) {
146 Trace.fatal(CLASS, this, "logFailureReply", "LogListener throwed RuntimeException",
147 e);
148 }
149 }
150 }
151
152 public synchronized void logMessage(final String text) {
153 for (int i = 0; i < loggers.size(); i++) {
154 try {
155 ((LogListener) loggers.get(i)).logMessage(text);
156 } catch (RuntimeException e) {
157 Trace.fatal(CLASS, this, "logMessage", "LogListener throwed RuntimeException", e);
158 }
159 }
160 }
161
162
163 }