source: trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCMonitorOutputWriter.java @ 842

Last change on this file since 842 was 842, checked in by fglaser, 12 years ago
  • OutputFormat? of JFCMonitor changed:
  • Components are printed, when they are created
  • Events hold hash values for components instead of full source path
  • Property svn:mime-type set to text/plain
File size: 1.4 KB
Line 
1package de.ugoe.cs.quest.jfcmonitor;
2
3import java.io.IOException;
4import java.io.OutputStreamWriter;
5
6import de.ugoe.cs.util.StringTools;
7/**
8 * <p>
9 * This class is used as wrapper for writers for JFCMonitor logs.
10 * </p>
11 * @author Fabian Glaser
12 * @version 1.0
13 *
14 */
15public class JFCMonitorOutputWriter{
16         /**
17     * <p>
18     * Writer for logging events.
19     * </p>
20     */
21    final private OutputStreamWriter outputWriter;
22   
23    /**
24     * <p>
25     * Constructor. Creates a new JFCMonitorOutputWriter with a given {@link OutputStreamWriter}, where the
26     * monitored information is written to. It writes log header information on construction to
27     * given OutputStreamWriter. 
28     * </p>
29     *
30     * @param outputWriter
31     *            writer for the logged information
32     */
33   
34    public JFCMonitorOutputWriter(OutputStreamWriter outputWriter) {
35        this.outputWriter = outputWriter;
36        try {
37            outputWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
38            outputWriter.write("<sessions>" + StringTools.ENDLINE);
39        }
40        catch (IOException e) {
41            System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage());
42        }
43    }
44   
45    public void write(String str){
46        try {
47                        outputWriter.write(str);
48                        outputWriter.flush();
49                } catch (IOException e) {
50                System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage());
51                }
52    }
53}
Note: See TracBrowser for help on using the repository browser.