Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 99   Methods: 11
NCLOC: 44   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LogListenerImpl.java - 54,5% 54,5% 54,5%
coverage coverage
 1    /* $Id: LogListenerImpl.java,v 1.1 2007/04/01 07:59:49 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.log;
 19   
 20    import java.io.PrintStream;
 21    import java.net.URL;
 22    import java.text.SimpleDateFormat;
 23    import java.util.Date;
 24   
 25    /**
 26    * Listener that writes events to a stream.
 27    *
 28    * @version $Revision: 1.1 $
 29    * @author Michael Meyling
 30    */
 31    public final class LogListenerImpl implements LogListener {
 32   
 33    /** Stream for output. */
 34    private PrintStream out = System.out;
 35   
 36    /** Timestamp format. */
 37    private static final SimpleDateFormat FORMATTER
 38    = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss,SSS");
 39   
 40    /**
 41    * Constructor.
 42    */
 43  3 public LogListenerImpl() {
 44  3 this(System.out);
 45    }
 46   
 47    /**
 48    * Constructor.
 49    *
 50    * @param stream Print to this stream.
 51    */
 52  3 public LogListenerImpl(final PrintStream stream) {
 53  3 this.out = stream;
 54    }
 55   
 56    /**
 57    * Set output stream.
 58    *
 59    * @param stream Output stream.
 60    */
 61  0 public final void setPrintStream(final PrintStream stream) {
 62  0 this.out = stream;
 63    }
 64   
 65  0 public final void logMessageState(final String text, final URL url) {
 66  0 out.println(getTimestamp() + " state: " + text + "\n\t" + url);
 67    }
 68   
 69  15 public final void logFailureState(final String text, final URL url,
 70    final String description) {
 71  15 out.println(getTimestamp() + " failure: " + text + "\n\t" + url + "\n\t" + description);
 72    }
 73   
 74  41 public final void logSuccessfulState(final String text, final URL url) {
 75  41 out.println(getTimestamp() + " success: " + text + "\n\t" + url);
 76    }
 77   
 78  78 private static final String getTimestamp() {
 79  80 return FORMATTER.format(new Date()).toString();
 80    }
 81   
 82  0 public void logRequest(final String text) {
 83  0 out.println(getTimestamp() + " request: " + text);
 84    }
 85   
 86  22 public final void logMessage(final String text) {
 87  24 out.println(getTimestamp() + " " + text);
 88    }
 89   
 90   
 91  0 public void logSuccessfulReply(final String text) {
 92  0 out.println(getTimestamp() + " reply: " + text);
 93    }
 94   
 95  0 public void logFailureReply(final String text, final String description) {
 96  0 out.println(getTimestamp() + " reply: " + text + "\n\t" + description);
 97    }
 98   
 99    }