© 2002 - Lorne Brinkman
www.TheObjectGuy.com
Lorne@TheObjectGuy.com

com.bitfactoryinc.logging
Class MemoryLogger

java.lang.Object
  |
  +--com.bitfactoryinc.logging.Logger
        |
        +--com.bitfactoryinc.logging.MemoryLogger

public class MemoryLogger
extends Logger

Instances of this class keep track of LogEntries in memory. The LogEntries can be dumped out to another Logger at any time, if desired. The capacity instance variable represents the maximum number of LogEntries to retain.


Field Summary
private  int capacity
           
private  java.util.LinkedList logEntries
           
 
Fields inherited from class com.bitfactoryinc.logging.Logger
application, defaultFilterClass, defaultFormatterClass, enabled, filter, formatter
 
Constructor Summary
MemoryLogger()
           
MemoryLogger(int aCapacity)
           
MemoryLogger(MemoryLogger aMemoryLogger)
          This is a copy constructor.
 
Method Summary
 void clear()
          Clear all the LogEntries
 MemoryLogger copy()
          a convenience method that just calls the copy constructor
protected  boolean doLog(LogEntry aLogEntry)
          If my capacity has been reached, remove the oldest entry.
 int getCapacity()
           
 LogEntry[] getLog()
          Return an Array of LogEntries
protected  java.util.LinkedList getLogEntries()
           
 void logAllTo(Logger aLogger)
          Dump all the LogEntries to aLogger
 void setCapacity(int newCapacity)
           
protected  void setLogEntries(java.util.LinkedList newLogEntries)
           
 int size()
          Return the number of LogEntries currently held
 boolean transferTo(Logger aLogger)
          This differs from logAllTo in that successfully logged entries are removed from me.
 
Methods inherited from class com.bitfactoryinc.logging.Logger
getApplication, getDefaultFilterClass, getDefaultFormatterClass, getFilter, getFormatter, getSeverityThreshold, isEnabled, log, log, log, logCritical, logCritical, logDebug, logDebug, logError, logError, logFatal, logFatal, logInfo, logInfo, logStatus, logStatus, logWarning, logWarning, setApplication, setDefaultFilter, setDefaultFilterClass, setDefaultFormatter, setDefaultFormatterClass, setEnabled, setFilter, setFormatter, setSeverityThreshold, shouldLog, writeToLog
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

capacity

private int capacity

logEntries

private java.util.LinkedList logEntries
Constructor Detail

MemoryLogger

public MemoryLogger()

MemoryLogger

public MemoryLogger(int aCapacity)

MemoryLogger

public MemoryLogger(MemoryLogger aMemoryLogger)
This is a copy constructor. Accomplish the copying by simply logging to the new instance.
Method Detail

clear

public void clear()
Clear all the LogEntries

copy

public MemoryLogger copy()
a convenience method that just calls the copy constructor

doLog

protected boolean doLog(LogEntry aLogEntry)
If my capacity has been reached, remove the oldest entry. Add the new entry to the collection.
Overrides:
doLog in class Logger

getCapacity

public int getCapacity()

getLog

public LogEntry[] getLog()
Return an Array of LogEntries

getLogEntries

protected java.util.LinkedList getLogEntries()

logAllTo

public void logAllTo(Logger aLogger)
Dump all the LogEntries to aLogger

setCapacity

public void setCapacity(int newCapacity)

setLogEntries

protected void setLogEntries(java.util.LinkedList newLogEntries)

size

public int size()
Return the number of LogEntries currently held

transferTo

public boolean transferTo(Logger aLogger)
This differs from logAllTo in that successfully logged entries are removed from me. Also, a doLog message is sent, as opposed to log. Also, I stop trying to log once I get a failure. Return true if everything logged successfully.

© 2002 - Lorne Brinkman
www.TheObjectGuy.com
Lorne@TheObjectGuy.com