1 package util;
2
3 import java.io.*;
4 import java.util.*;
5
6
11 public class IntellegoLog
12 {
13 private File log; private FileWriter fw;
16
19 public IntellegoLog()
20 {
21 log=new File("logs/Intellego.log");
23
24 Date date=new Date();
26 String temp=date.toString();
27 String time=temp.substring(0,19);
28
29 try
31 {
32 log.createNewFile();
33 fw=new FileWriter(log);
34 fw.write("========================\n Intellego Log File\n========================\n\n");
35 fw.write("System started on: "+time+"\n\nMessages:\n\n");
36 fw.flush();
37 }
38 catch (Exception e)
39 {
40 System.out.println("IntellegoLog.init(): Failed to create log file: "+e);
41 }
42 }
43
44
49 public synchronized void addMessage(String message)
50 {
51 try
53 {
54 fw.write(message+"\n");
55 fw.flush();
56 }
57 catch (Exception e)
58 {
59 System.out.println("IntellegoLog.addMessage(): Failed to add log message: "+e);
60 }
61 }
62 }
63