1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
2 | * |
3 | * Copyright 2000-2014, 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 org.qedeq.base.trace.Trace; |
19 | |
20 | /** |
21 | * Listener that writes events to the trace. |
22 | * |
23 | * @author Michael Meyling |
24 | */ |
25 | public final class TraceListener implements LogListener { |
26 | |
27 | /** Last modules URL .*/ |
28 | private String lastModuleUrl = ""; |
29 | |
30 | /** |
31 | * Constructor. |
32 | */ |
33 | public TraceListener() { |
34 | // nothing to do |
35 | } |
36 | |
37 | public final void logMessageState(final String text, final String url) { |
38 | if (!lastModuleUrl.equals(url)) { |
39 | Trace.log(url); |
40 | lastModuleUrl = (url != null ? url : ""); |
41 | } |
42 | Trace.log(" state: " + text); |
43 | } |
44 | |
45 | public final void logFailureState(final String text, final String url, |
46 | final String description) { |
47 | if (!lastModuleUrl.equals(url)) { |
48 | Trace.log(url); |
49 | lastModuleUrl = (url != null ? url : ""); |
50 | } |
51 | Trace.log(" failure: " + text, description); |
52 | } |
53 | |
54 | public final void logSuccessfulState(final String text, final String url) { |
55 | if (!lastModuleUrl.equals(url)) { |
56 | Trace.log(url); |
57 | lastModuleUrl = (url != null ? url : ""); |
58 | } |
59 | Trace.log(" success: " + text); |
60 | } |
61 | |
62 | public void logRequest(final String text, final String url) { |
63 | if (!lastModuleUrl.equals(url)) { |
64 | Trace.log(url); |
65 | lastModuleUrl = (url != null ? url : ""); |
66 | } |
67 | Trace.log(" request: " + text); |
68 | } |
69 | |
70 | public final void logMessage(final String text) { |
71 | Trace.log(text); |
72 | } |
73 | |
74 | public void logSuccessfulReply(final String text, final String url) { |
75 | if (!lastModuleUrl.equals(url)) { |
76 | Trace.log(url); |
77 | lastModuleUrl = (url != null ? url : ""); |
78 | } |
79 | Trace.log(" reply: " + text); |
80 | } |
81 | |
82 | public void logFailureReply(final String text, final String url, final String description) { |
83 | if (!lastModuleUrl.equals(url)) { |
84 | Trace.log(url); |
85 | lastModuleUrl = (url != null ? url : ""); |
86 | } |
87 | Trace.log(" reply: " + text, description); |
88 | } |
89 | |
90 | } |