Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.common.logger
Class TLptsLogOutputListener

java.lang.Object
  extended by com.lapetus_ltd.api.common.logger.TLptsLogOutputListener
All Implemented Interfaces:
ILptsLogListener

public class TLptsLogOutputListener
extends java.lang.Object
implements ILptsLogListener

Class Description : This class writes the logs to a text file.

This class is used by the log dialog, when selected in the window.
The application can use this for the same reason if the log dialog is not implemented in the application.

$LastChangedRevision: 1177 $
$LastChangedDate:: 2010-11-09 15:27:48#$


Field Summary
(package private)  java.lang.String fileName
           
(package private)  boolean isMonthFirst
           
 
Constructor Summary
TLptsLogOutputListener(java.lang.String path, boolean isMonthFirst)
          This is the constructor for TLptsLogOutputListener.
 
Method Summary
 void closeOutput()
          Closes the log file.
 java.lang.String getFileName()
          Gets the full path name of the log file.
 boolean isReadyForOutput()
          Checks to see if the file will accept output.
 void newLogGenerated(TLptsLog log)
          
Implementation of ILptsLogListener.newLogGenerated(TLptsLog).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

final java.lang.String fileName

isMonthFirst

final boolean isMonthFirst
Constructor Detail

TLptsLogOutputListener

public TLptsLogOutputListener(java.lang.String path,
                              boolean isMonthFirst)
This is the constructor for TLptsLogOutputListener.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : No.

Notes :

Example :


 //Create a new TLptsLogOutputListener
 TLptsLogOutputListener logOutputListener = new TLptsLogOutputListener(TLptsFileUtil.getUserHomeLapetusDirectory(),false);
 ...
 logOutputListener.closeOutput();

 

Parameters:
path - the full path of the file to be saved.
isMonthFirst - If true the month is shown first in the date. Otherwise the day is first.
Method Detail

closeOutput

public void closeOutput()
Closes the log file.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes : No more logs can be written after closing.

Example :


 //Create a new TLptsLogOutputListener
 TLptsLogOutputListener logOutputListener = new TLptsLogOutputListener(TLptsFileUtil.getUserHomeLapetusDirectory(),false);
 ...
 logOutputListener.closeOutput();

 


getFileName

public java.lang.String getFileName()

Gets the full path name of the log file.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :

Example :


 //Create a new TLptsLogOutputListener and set as path the default path of the application
 TLptsLogOutputListener logOutputListener = new TLptsLogOutputListener(TLptsFileUtil.getUserHomeLapetusDirectory(),false);
 ...
 System.out.println("The log file name is " + logOutputListener.getFileName);

 RESULT: The result will show the user home lapetus directory with a unique filename, which is timestamped.
 

Returns:
The log file with '/' instead of '\'.

isReadyForOutput

public boolean isReadyForOutput()
Checks to see if the file will accept output.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 if (isReadyForOutput())
   System.out.println("The log file listener is ready for logs to be written to it.");

 

Returns:
true

newLogGenerated

public void newLogGenerated(TLptsLog log)

Implementation of ILptsLogListener.newLogGenerated(TLptsLog).
When the file is ready for updates, every log is written to the file. There is no filtering.

Specified by:
newLogGenerated in interface ILptsLogListener
Parameters:
log - is the new TLptsLog that occurs from the caught exception.


Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)