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

com.lapetus_ltd.api.common.logger
Class TLptsLog

java.lang.Object
  extended by com.lapetus_ltd.api.common.logger.TLptsLog

public class TLptsLog
extends java.lang.Object

Class Description : This is the log class used to contain a single log.

This object holds the messages from the application and from the exception (if it exists). It also holds the
type of log (ERROR, WARNING, MESSAGE, DEBUG) and the exception class (if it exists).
There is an ID on every log, which is 0 by default. If the application sets the ID in TLptsLogger.setRecipientId(int) then
all logs created after that will have the specified ID. This is a way to filter LOGS on the receiving end ILptsLogListener.
It can also be used to target certain receivers, that will only look at logs with the specific ID.

$LastChangedRevision: 1165 $
$LastChangedDate:: 2010-11-03 10:37:03#$


Constructor Summary
TLptsLog(TLptsLogger.LOG_TYPE type, java.lang.String message, java.lang.String supportingText, java.lang.Exception exception, int id)
          This is the Constructor for the TLptsLog class.
 
Method Summary
 java.lang.Exception getException()
          Gets the Exception of the TLptsLog.
 java.lang.String getExceptionMessage()
          Gets the message of the Exception.
 int getId()
           Gets the current ID set by TLptsLogger.setRecipientId(int).
 java.lang.String getMessage()
          Gets the message set by the application for the log.
 java.lang.String getSupportingText()
           Gets the support text set by the application.
 java.sql.Timestamp getTimestamp()
          Gets the timeStamp of the log.
 TLptsLogger.LOG_TYPE getType()
           Gets the type of the Log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsLog

public TLptsLog(TLptsLogger.LOG_TYPE type,
                java.lang.String message,
                java.lang.String supportingText,
                java.lang.Exception exception,
                int id)
This is the Constructor for the TLptsLog class.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : No.

Notes : the application should call TLptsLogger.logError(java.lang.String, java.lang.Exception) or the other logXXX functions to generate a log.
It is not recommended to create the log ourselves, using the constructor.

Example :


 try
 {
   // Doing something here that throws and exception.
 } catch (Exception e)
 {
   // Something unexpected happened and the application caught it.
   TLptsLogger.logError("The application threw an exception.",e);
 }
 ...
 // In one of the listeners of the logger
 public class TLogListener implements ILptsLogListener
 {
   void newLogGenerated(TLptsLog log)
   {
      //Every time TLptsLogger catches an exception, it creates a new TLptsLog()
      //This TLptsLog contains all the information we want for that exception.
      //First we can determine the type of the TLptsLog (Error,Message,Debug,Warning,Reset)
      if (log.getType()==TLptsLogger.LOG_TYPE.ERROR)
      {
        System.out.println("Error ID: " + log.getId());
        //TLptsLog contains the text message we set when we catch the exception
        System.out.println("Error logger: " + log.getMessage());
        //Also contains the message of the exception
        System.out.println("Exception message: " + log.getExceptionMessage());
        //The application also sets a support text
        System.out.println("Supporting Text: " + log.getSupportingText());
        // With getTimestamp we can identify the exact time of the log (down to milliseconds)
        System.out.println("Time : " + log.getTimestamp());
        //Finally the TLptsLog contains the object of the Exception.
        processException(log.getException());
      }
   }
 }

 

Parameters:
type - is the Type of the Exception (Error,Message,Debug,Warning,Reset)
message - The message for the log
supportingText - Support text for the log
exception - The exception object
id - The recipient ID for filtering (default is 0 from TLptsLogger)
Method Detail

getException

public java.lang.Exception getException()
Gets the Exception of the TLptsLog.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : Yes.

Notes : If the log is generated from an EXCEPTION, then that will be included here.

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
the exception of the TLptsLog

getExceptionMessage

public java.lang.String getExceptionMessage()
Gets the message of the Exception.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : No. Empty String in worst case.

Notes :

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
Returns an empty string if the exception is null. Otherwise, it returns the localised message if it exists. Otherwise, it returns the default message if it exists. If all of the above do not exist, it returns the name of the exception class.

getId

public int getId()

Gets the current ID set by TLptsLogger.setRecipientId(int).

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : Yes.

Notes : Use this to filter logs within the application.
Inside db-JAPI this is ignored.

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
the ID set in the Logger.

getMessage

public java.lang.String getMessage()
Gets the message set by the application for the log.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : Yes. Message can set to null by the application.

Notes : The message could be a warning, debug, plain informational message or error.

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
TLptsLog message.

getSupportingText

public java.lang.String getSupportingText()

Gets the support text set by the application.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : Yes. Supporting text can be set to null.

Notes :

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
supporting text for the exception.

getTimestamp

public java.sql.Timestamp getTimestamp()
Gets the timeStamp of the log.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : No.

Notes : TimeStamp is set by the constructor.

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
returns the TimeStamp of the exception in milliseconds from 1970-01-01.

getType

public TLptsLogger.LOG_TYPE getType()

Gets the type of the Log.

Thread Safe : Yes.

Spawns its own Thread : No.

May Return NULL : Yes.

Notes : Type can be Error, Message, Debug, Warning, Reset.

Example :


 Refer to example in constructor TLptsLog.

 

Returns:
returns one of the following : TLptsLogger.LOG_TYPE.ERROR TLptsLogger.LOG_TYPE.WARNING TLptsLogger.LOG_TYPE.DEBUG TLptsLogger.LOG_TYPE.MESSAGE TLptsLogger.LOG_TYPE.RESET TLptsLogger


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