TwilightMinds.Log
Class Log

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--TwilightMinds.Log.Log
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FlatFileLog

public abstract class Log
extends java.lang.Thread

An instance of the Log abstract class provides the functionality to represent a single log. It stores LogEntry objects that are passed to it and runs as a thread to record and ease these objects. Information that cannot be recorded is written to System.err as a last resort.

Working Log classes are derived from the Log class by overwriting the private recordLogEntry(LogEntry logentry) method.

Author: Reason
Last Modified: 11/23/00

------------------------------------------------

Copyright (C) 2000 Twilight Minds. All rights reserved.

This Java package is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this package; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Alternatively, a copy can be obtained from the Twilight Minds web site: http://www.twilightminds.com/GNU-LGPL.html

Twilight Minds Design Group http://www.twilightminds.com/


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Log(java.lang.String inputname)
          The standard constructor for a Log object.
Log(java.lang.String inputname, long inputcycledelay)
          Constructor allowing for specification of the cycle delay between periods of recording LogEntry objects.
 
Method Summary
 boolean addLogEntry(LogEntry logentry)
          Add a LogEntry object to the queue waiting to be written.
 long getCycleDelay()
          Return the delay in milliseconds between each cycle during which the Log writes out pending LogEntry objects to the log file.
 java.lang.String getLogName()
          Return the identifying name of this log.
 boolean isLogging()
          Return the state of the log.
protected abstract  void recordLogEntry(LogEntry logentry)
          This abstract method must be overwritten in child classes to provide an implementation for writing the LogEntry information to a store, be that file, database, etc, etc.
 void run()
          The run() method for this class runs through the LogEntry objects waiting to be recorded and deletes these objects as this happens.
 void setCycleDelay(long inputcycledelay)
          Set the delay in milliseconds between each cycle during which the Log writes out pending LogEntry objects to the log file.
 void startLogging()
          Set this Log object to accept new LogEntry objects and begin running as a thread while writing to the log file.
 void stopLogging()
          Set this Log object to reject new LogEntry objects.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Log

public Log(java.lang.String inputname)
The standard constructor for a Log object.

Log

public Log(java.lang.String inputname,
           long inputcycledelay)
Constructor allowing for specification of the cycle delay between periods of recording LogEntry objects.
Method Detail

getLogName

public java.lang.String getLogName()
Return the identifying name of this log.

isLogging

public boolean isLogging()
Return the state of the log. True indicates that the log is accepting entries, false that it is not.

startLogging

public void startLogging()
Set this Log object to accept new LogEntry objects and begin running as a thread while writing to the log file.

stopLogging

public void stopLogging()
Set this Log object to reject new LogEntry objects. The Log will write out LogEntry objects that have already been received and will then stop running as a thread.

getCycleDelay

public long getCycleDelay()
Return the delay in milliseconds between each cycle during which the Log writes out pending LogEntry objects to the log file.

setCycleDelay

public void setCycleDelay(long inputcycledelay)
Set the delay in milliseconds between each cycle during which the Log writes out pending LogEntry objects to the log file.

addLogEntry

public boolean addLogEntry(LogEntry logentry)
Add a LogEntry object to the queue waiting to be written. Returns false if this Log is not accepting new LogEntry objects.

run

public void run()
The run() method for this class runs through the LogEntry objects waiting to be recorded and deletes these objects as this happens. If a LogEntry cannot be recorded for whatever reason, then the information is written to System.err.
Overrides:
run in class java.lang.Thread

recordLogEntry

protected abstract void recordLogEntry(LogEntry logentry)
                                throws java.lang.Exception
This abstract method must be overwritten in child classes to provide an implementation for writing the LogEntry information to a store, be that file, database, etc, etc. An Exception must be thrown if the process of recording the LogEntry fails.