01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2011, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
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 /**
33 * Constructor.
34 */
35 public LogListenerImpl() {
36 this(System.out);
37 }
38
39 /**
40 * Constructor.
41 *
42 * @param stream Print to this stream.
43 */
44 public LogListenerImpl(final PrintStream stream) {
45 this.out = stream;
46 }
47
48 /**
49 * Set output stream.
50 *
51 * @param stream Output stream.
52 */
53 public final void setPrintStream(final PrintStream stream) {
54 this.out = stream;
55 }
56
57 public final void logMessageState(final String text, final String url) {
58 out.println(DateUtility.getTimestamp() + " state: " + text + "\n\t" + url);
59 }
60
61 public final void logFailureState(final String text, final String url,
62 final String description) {
63 out.println(DateUtility.getTimestamp() + " failure: " + text + "\n\t" + url + "\n\t"
64 + description);
65 }
66
67 public final void logSuccessfulState(final String text, final String url) {
68 out.println(DateUtility.getTimestamp() + " success: " + text + "\n\t" + url);
69 }
70
71 public void logRequest(final String text) {
72 out.println(DateUtility.getTimestamp() + " request: " + text);
73 }
74
75 public final void logMessage(final String text) {
76 out.println(DateUtility.getTimestamp() + " " + text);
77 }
78
79
80 public void logSuccessfulReply(final String text) {
81 out.println(DateUtility.getTimestamp() + " reply: " + text);
82 }
83
84 public void logFailureReply(final String text, final String description) {
85 out.println(DateUtility.getTimestamp() + " reply: " + text + "\n\t" + description);
86 }
87
88 }
|