It is used to write a log file explaining the steps the program went through during its execution. More...
Public Member Functions | |
LogWriter () | |
Creates an instance of LogWriter and writes the current date in it. <../..> | |
void | append (String line) |
Appends the String "line" at the end of the log file and prints it on the screen. <../..> | |
void | finish () |
Writes the finishing time in the log file. <../..> | |
Package Attributes | |
String | logName |
The name of the written file. <../..> |
It is used to write a log file explaining the steps the program went through during its execution.
Definition at line 13 of file LogWriter.java.
myShell.LogWriter.LogWriter | ( | ) |
Creates an instance of LogWriter and writes the current date in it.
Definition at line 32 of file LogWriter.java.
{ Calendar cal = Calendar.getInstance(); String date = cal.get(Calendar.DATE) + "-" + (cal.get(Calendar.MONTH)+1) + "-" + cal.get(Calendar.YEAR) + "-(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND) + ")"; this.logName = "../data/log/" + date + ".log" ; this.append(" ----- started at : " + date + "\n\n"); }
void myShell.LogWriter.append | ( | String | line | ) |
Appends the String "line" at the end of the log file and prints it on the screen.
line | The line to be appended in the file. |
Definition at line 51 of file LogWriter.java.
{ System.out.println(line); try { BufferedWriter logFile = new BufferedWriter (new FileWriter(this.logName,true)); logFile.write(line); logFile.newLine(); logFile.close(); } catch (Exception e) { e.printStackTrace(); } }
void myShell.LogWriter.finish | ( | ) |
Writes the finishing time in the log file.
Definition at line 69 of file LogWriter.java.
{ Calendar cal = Calendar.getInstance(); String date = cal.get(Calendar.DATE) + "-" + (cal.get(Calendar.MONTH)+1) + "-" + cal.get(Calendar.YEAR) + "-(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND) + ")"; append("\n ----- finished at : " + date); }
String myShell.LogWriter.logName [package] |
The name of the written file.
Definition at line 22 of file LogWriter.java.