update dev300-m58
[ooovba.git] / scripting / workben / installer / LogStream.java
blob9244859f5f4eca0bfd75e0670fc95b44050b7890
1 package installer;
2 import java.io.PrintStream;
3 import java.io.FileOutputStream;
5 import java.util.Date;
6 import java.text.DateFormat;
7 import java.text.SimpleDateFormat;
10 //import java.io.PrintWriter;
11 public class LogStream extends PrintStream
13 static final private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z: ");
15 private String getTimeStamp()
17 String timeStamp = formatter.format( new Date() );
18 return timeStamp;
20 public LogStream( String logFileName ) throws java.io.FileNotFoundException
22 super( new FileOutputStream( logFileName ) );
24 public void println(String x)
26 super.println( getTimeStamp() + x );
28 public static void main(String[] args)
30 if ( args.length > 0 )
32 try
34 LogStream log = new LogStream( args[0] );
35 System.setErr(log);
36 System.setOut(log);
37 System.out.println("Test from logger from out");
38 System.err.println("Test from logger from err");
39 System.out.println("finised test from out");
40 System.err.println("finised test from err");
42 catch( java.io.FileNotFoundException fe )
44 System.err.println("Error creating logStream: " + fe );
45 fe.printStackTrace();
48 else
50 System.err.println("specify log file java LogStream [logfile]");
51 System.exit(1);