Class LocalLog

java.lang.Object
  |
  +--LocalLog
All Implemented Interfaces:
Log

public class LocalLog
extends java.lang.Object
implements Log

A LocalLog is an implementation of the Log interface that resides in the instrumented program's memory. We implement it as a fixed-sized Collection along with the regular expression inclusion filter.


Constructor Summary
LocalLog(int logSize)
          Constructor specifies the size of the log.
 
Method Summary
 void add(LogRecord record)
          Adds a record to the log, assuming it matches the pattern given to setFilter.
 LogRecord[] getAll(long windowMS)
          Returns all LogRecords whose timestamps are within a window of time.
 void setFilter(java.lang.String strPat)
          Sets a regular-expression filter on what events are stored.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalLog

public LocalLog(int logSize)
Constructor specifies the size of the log. The LogRecords are stored in a Collection; in our case an ArrayList.

Parameters:
logSize - the number of records we can store in the log.
Method Detail

add

public void add(LogRecord record)
Adds a record to the log, assuming it matches the pattern given to setFilter. If the log is full, then the oldest record is removed before adding the new one.

Specified by:
add in interface Log

getAll

public 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. Also, the returned array will be in sorted order.

Specified by:
getAll in interface Log
Parameters:
windowMS - return all records from the last [windowMS] milliseconds.

setFilter

public void setFilter(java.lang.String strPat)
Description copied from interface: Log
Sets a regular-expression filter on what events are stored.

Specified by:
setFilter in interface Log
Parameters:
strPat - is a regular expression to match against; if the event portion of a LogRecord passed to add, above, matches this expression, then the LogRecord is retained, and is otherwise discarded.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object