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