net.spy.log
Class SpyLogFlusher

java.lang.Object
  extended byjava.lang.Thread
      extended bynet.spy.SpyThread
          extended bynet.spy.log.SpyLogFlusher
All Implemented Interfaces:
Runnable

public class SpyLogFlusher
extends SpyThread

SpyLogFlusher does the actual work of SpyLog. This is where the log queue is flushed and placed in permanent storage.

By default, log entries are written to the file described in the variable logfile.

Classes overriding this will be most interested in the protected method doFlush(). doFlush is called on a given interval when it's time to flush the logs. The logs are available via a SpyLog object called ``log_object.'' To get a list of all log entries that need to be flushed, the following piece of code may be executed:
Vector v = log_object.flush();


Field Summary
 String logfile
          Path to the logfile.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SpyLogFlusher(String name)
          Get a SpyFlusher for the given queue.
SpyLogFlusher(String name, ThreadGroup t)
          Get a SpyFlusher for the given queue in the given ThreadGroup
 
Method Summary
 void close()
          Stop was taken and deprecated by those fools at Javasoft.
protected  void configure()
          Do additional configuration stuff here.
protected  void doFlush()
          This method should writes the log entries to their final destination.
protected  void finalize()
           
protected  Vector flush()
          Return the current queue of things to be logged
 long getSleepTime()
          Get the current sleep time.
 int queueSize()
          Get the current size of the queue.
 void run()
          Periodically process the log queue.
protected  void setSleepTime(long sleepTime)
          Set the sleep time between flushes.
 String toString()
          Get a string describing this thingy.
 
Methods inherited from class net.spy.SpyThread
getLogger
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logfile

public String logfile
Path to the logfile. The default logfile is /tmp/spy.log, but this can be overridden.

Constructor Detail

SpyLogFlusher

public SpyLogFlusher(String name)
Get a SpyFlusher for the given queue.


SpyLogFlusher

public SpyLogFlusher(String name,
                     ThreadGroup t)
Get a SpyFlusher for the given queue in the given ThreadGroup

Method Detail

setSleepTime

protected void setSleepTime(long sleepTime)
Set the sleep time between flushes.


getSleepTime

public long getSleepTime()
Get the current sleep time.


toString

public String toString()
Get a string describing this thingy.


configure

protected void configure()
Do additional configuration stuff here.


flush

protected Vector flush()
Return the current queue of things to be logged


queueSize

public int queueSize()
Get the current size of the queue.


doFlush

protected void doFlush()
                throws Exception
This method should writes the log entries to their final destination. The default implementation writes the log entries to a file. This method should probably be overridden to be useful.

Throws:
Exception

close

public void close()
Stop was taken and deprecated by those fools at Javasoft. I use close here because it's kinda the right thing to do, as we're closing the log...sorta.


run

public void run()
Periodically process the log queue. You probably don't want to override this.


finalize

protected void finalize()
                 throws Throwable
Throws:
Throwable