cmsc433.p1
Interface Log

All Known Subinterfaces:
FilterLog
All Known Implementing Classes:
BasicFilterLog, BasicLog, NullLog, SplitLog

public interface Log

A Log collects and performs computations on LogRecords. This is an interface because we may implement logs differently, e.g. as a local array, as a Collection, as a remote server or database, etc.


Method Summary
 void add(LogRecord record)
          Stores a LogRecord in the Log.
 java.util.List<LogRecord> flush()
          Returns all LogRecords kept in the log, emptying the log.
 java.util.List<LogRecord> getAll(long windowMS)
          Returns all LogRecords whose timestamps are within a window of time.
 void register(Listener<LogRecord> listener)
          Registers a listener that whose notify() method will be called whenever a record is added to this log; the first argument of notify() is the log itself, and the second is the LogRecord that was added.
 void unregister(Listener<LogRecord> listener)
          Removes a previously-registered listener.
 

Method Detail

add

void add(LogRecord record)
Stores a LogRecord in the Log. Implementations may choose to only add some logs (e.g. logs matching a given pattern).


getAll

java.util.List<LogRecord> getAll(long windowMS)
Returns all LogRecords whose timestamps are within a window of time. Note that inclusion is based on the timestamp of the LogRecord, not the time at which the record was stored in the Log. This is non-destructive; all records remain in the Log.

Parameters:
windowMS - return all records from the last [windowMS] milliseconds.

flush

java.util.List<LogRecord> flush()
Returns all LogRecords kept in the log, emptying the log.


register

void register(Listener<LogRecord> listener)
Registers a listener that whose notify() method will be called whenever a record is added to this log; the first argument of notify() is the log itself, and the second is the LogRecord that was added.

Parameters:
listener - The listener to register.

unregister

void unregister(Listener<LogRecord> listener)
Removes a previously-registered listener.

Parameters:
listener - The listener to remove. If this listener is not present, then unregister behaves as a no-op.