KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > wminstaller > tools > Logger


1 package de.webman.wminstaller.tools;
2
3 import java.io.*;
4
5 /**
6  * a super simplistic logger class for the database installer
7  **/

8 public class Logger {
9     PrintStream _out = null;
10
11     public Logger () {
12     }
13
14     public Logger (OutputStream stream)
15         throws IOException
16     {
17         if (stream instanceof PrintStream)
18             _out = (PrintStream)stream;
19         else
20             _out = new PrintStream(stream);
21     }
22     
23     public Logger (File file)
24         throws IOException
25     {
26         _out = new PrintStream(new FileOutputStream(file));
27     }
28
29     public Logger (String JavaDoc file)
30         throws IOException
31     {
32         _out = new PrintStream(new FileOutputStream(file));
33     }
34     
35
36     public void close() {
37         if (_out != null)
38             _out.close();
39     }
40
41     /**
42      * writes an info line to the log file
43      */

44     public void info(String JavaDoc line) {
45         if (_out != null)
46             _out.println(line);
47     }
48
49     /**
50      * writes an error line to the log file
51      */

52     public void error(String JavaDoc line) {
53         if (_out != null)
54             _out.println("ERROR: " + line);
55     }
56 }
57
Popular Tags