Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
29   116   22   2.9
24   64   0.76   10
10     2.2  
1    
 
  LogListenerImpl       Line # 27 29 22 90.5% 0.9047619
 
  (3)
 
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.io.PrintStream;
19   
20    import org.qedeq.base.utility.DateUtility;
21   
22    /**
23    * Listener that writes events to a stream.
24    *
25    * @author Michael Meyling
26    */
 
27    public final class LogListenerImpl implements LogListener {
28   
29    /** Stream for output. */
30    private PrintStream out = System.out;
31   
32    /** For this module we logged the last event. */
33    private String lastModuleUrl = "";
34   
35    /**
36    * Constructor.
37    */
 
38  3 toggle public LogListenerImpl() {
39  3 this(System.out);
40    }
41   
42    /**
43    * Constructor.
44    *
45    * @param stream Print to this stream.
46    */
 
47  29 toggle public LogListenerImpl(final PrintStream stream) {
48  29 this.out = stream;
49    }
50   
51    /**
52    * Set output stream.
53    *
54    * @param stream Output stream.
55    */
 
56  1 toggle public final void setPrintStream(final PrintStream stream) {
57  1 this.out = stream;
58    }
59   
 
60  184 toggle public final void logMessageState(final String text, final String url) {
61  184 if (!lastModuleUrl.equals(url)) {
62  5 out.println(url);
63  5 lastModuleUrl = (url != null ? url : "");
64    }
65  184 out.println(DateUtility.getTimestamp() + " state: " + text);
66    }
67   
 
68  18 toggle public final void logFailureState(final String text, final String url,
69    final String description) {
70  18 if (!lastModuleUrl.equals(url)) {
71  2 out.println(url);
72  2 lastModuleUrl = (url != null ? url : "");
73    }
74  18 out.println(DateUtility.getTimestamp() + " failure: " + text + "\n\t"
75    + description);
76    }
77   
 
78  51 toggle public final void logSuccessfulState(final String text, final String url) {
79  51 if (!lastModuleUrl.equals(url)) {
80  5 out.println(url);
81  5 lastModuleUrl = (url != null ? url : "");
82    }
83  51 out.println(DateUtility.getTimestamp() + " success: " + text);
84    }
85   
 
86  24 toggle public void logRequest(final String text, final String url) {
87  24 if (!lastModuleUrl.equals(url)) {
88  5 out.println(url);
89  5 lastModuleUrl = (url != null ? url : "");
90    }
91  24 out.println(DateUtility.getTimestamp() + " request: " + text);
92    }
93   
 
94  25 toggle public final void logMessage(final String text) {
95  25 lastModuleUrl = "";
96  25 out.println(DateUtility.getTimestamp() + " " + text);
97    }
98   
99   
 
100  21 toggle public void logSuccessfulReply(final String text, final String url) {
101  21 if (!lastModuleUrl.equals(url)) {
102  5 out.println(url);
103  5 lastModuleUrl = (url != null ? url : "");
104    }
105  21 out.println(DateUtility.getTimestamp() + " reply: " + text);
106    }
107   
 
108  11 toggle public void logFailureReply(final String text, final String url, final String description) {
109  11 if (!lastModuleUrl.equals(url)) {
110  7 out.println(url);
111  7 lastModuleUrl = (url != null ? url : "");
112    }
113  11 out.println(DateUtility.getTimestamp() + " reply: " + text + "\n\t" + description);
114    }
115   
116    }