Holger's
Java API

com.antelmann.util.logging
Class LoggerCache

java.lang.Object
  extended by com.antelmann.util.logging.LoggerCache
All Implemented Interfaces:
Filter<LogEntry>, LogWriter

public class LoggerCache
extends Object
implements LogWriter

provides a simple mechanism to cache LogEntries from a Logger

Since:
01.08.2008, 20:27:37
Author:
Holger Antelmann

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
LoggerCache()
          uses a size of 10
LoggerCache(int cacheSize)
           
 
Method Summary
 boolean accept(LogEntry entry)
          returns true only if the given entry is accepted by this filter
 LogEntry[] getCache()
          always returns an array of the size of the cache with the current content where the first element is the latest
 int getCacheSize()
           
 Filter<? super LogEntry> getFilter()
           
 void setCacheSize(int cacheSize)
           
 void setFilter(Filter<? super LogEntry> filter)
           
 void write(LogEntry entry)
          writes the given LogEntry to the log of this LogWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerCache

public LoggerCache()
uses a size of 10


LoggerCache

public LoggerCache(int cacheSize)
Method Detail

getCacheSize

public int getCacheSize()

setCacheSize

public void setCacheSize(int cacheSize)

write

public void write(LogEntry entry)
           throws LogException
Description copied from interface: LogWriter
writes the given LogEntry to the log of this LogWriter. This method must not check whether entries are accepted, as the Logger class will only call this method once checked that this LogWriter accepts the given entry.

Specified by:
write in interface LogWriter
Throws:
LogException - if an error occurred while writing the log

getCache

public LogEntry[] getCache()
always returns an array of the size of the cache with the current content where the first element is the latest


getFilter

public Filter<? super LogEntry> getFilter()

setFilter

public void setFilter(Filter<? super LogEntry> filter)

accept

public boolean accept(LogEntry entry)
Description copied from interface: Filter
returns true only if the given entry is accepted by this filter

Specified by:
accept in interface Filter<LogEntry>


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads