SOURCECODE

How to... define a new LogEntry


Description:
A LogEntry is what is being put into the LogOutputStream when logging an event. The information needed for the Log is provided by the two methods public String toString() and public Date getLogDate()
These are the methods to be redefined in order to suit your event log. By default they return "Object logged: " + getLogDate() and the present system date at the point of logging.
In our OpenLogEntry we keep the system date as return of getLogDate, but redefine the toString() method to return the String "Counter opened". The entry displayed on the LogTableForm will then be the system date at the point of opening the videomachine's counter and the text "Counter opened".
To learn more about the example, please refer to "How to log the opening and closing of a SalesPoint", "How to define a Log", "How to implement the interface Loggable", "How to display log file contents" and for general information please go to "How to understand Logging".

ToDo's:
  1. Create a new subclass of LogEntry
  2. Redefine the toString() method to return a suitable text for the event
  3. Use the LogEntry to be returned by the method getLogData() of the implementation of Loggable


Uses:
LogEntry  Loggable  Log  



SourceCode

import log.*;
import java.util.*;

 1
//a new subclass of LogEntry
public class OpenLogEntry extends LogEntry {

     2
    //here is where the Text of the LogEntry is being defined
    public String toString() {
        return "Counter opened";
    }
}