org.safs.logging
Class LogItem

java.lang.Object
  extended by org.safs.logging.LogItem
Direct Known Subclasses:
FileLogItem

public abstract class LogItem
extends java.lang.Object

This class is the abstract representation of a single log in a log facility.

The type of the log (i.e. tool-specific, plain text, xml etc.) is identified by the public mode field. Valid values are the LOGMODE constants defined by AbstractLogFacility. Attributes common to all log types, such as name, log level, enabled state, and closed state etc, are encapsulated in this class.

This class declares two abstract methods: logMessage and close. They should be implmented by subclasses for specific log types that know how to provide those functionality. A concrete log facility could include instances of appropriate subclasses of LogItem and delegate its logging functions to them.

See Also:
AbstractLogFacility

Field Summary
protected  boolean closed
           
 boolean enabled
          The enabled state of this log.
 int level
          The log level of this log item (one of the LOGLEVEL constants defined by AbstractLogFacility).
 long mode
          The type of this log item (one of the LOGMODE constants defined by AbstractLogFacility).
 java.lang.String name
          The name of this log item.
 
Constructor Summary
LogItem(java.lang.String name, long mode)
          Creates a disabled log and sets its log level to LOGLEVEL_INFO.
LogItem(java.lang.String name, long mode, boolean enabled)
          Creates a log and sets its log level to LOGLEVEL_INFO.
LogItem(java.lang.String name, long mode, int level, boolean enabled)
          Creates a LogItem.
 
Method Summary
abstract  void close()
          Closes this log.
static java.lang.String dateTime(int dateOrTime)
          Returns the string representation of the current date or time.
 boolean isClosed()
          Tests if this log is closed.
abstract  void logMessage(java.lang.String msg, java.lang.String desc, int msgType)
          Logs a message to this log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public java.lang.String name
The name of this log item.


mode

public long mode
The type of this log item (one of the LOGMODE constants defined by AbstractLogFacility).


level

public int level
The log level of this log item (one of the LOGLEVEL constants defined by AbstractLogFacility).


enabled

public boolean enabled
The enabled state of this log.


closed

protected boolean closed
Constructor Detail

LogItem

public LogItem(java.lang.String name,
               long mode,
               int level,
               boolean enabled)
Creates a LogItem.

Parameters:
name - the name of this log.
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
level - the log level for this log.
enabled - true to enable this log; false to disable.

LogItem

public LogItem(java.lang.String name,
               long mode,
               boolean enabled)
Creates a log and sets its log level to LOGLEVEL_INFO.

Parameters:
name - the name of this log.
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
enabled - true to enable this log; false to disable.

LogItem

public LogItem(java.lang.String name,
               long mode)
Creates a disabled log and sets its log level to LOGLEVEL_INFO.

Parameters:
name - the name of this log.
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
Method Detail

isClosed

public boolean isClosed()
Tests if this log is closed.

Returns:
true if this log is closed; false if it is open.

dateTime

public static java.lang.String dateTime(int dateOrTime)
Returns the string representation of the current date or time.

Parameters:
dateOrTime - 0 to return date; 1 to return time

logMessage

public abstract void logMessage(java.lang.String msg,
                                java.lang.String desc,
                                int msgType)
Logs a message to this log.

Parameters:
msg - the message to log.
desc - additional description to log.
msgType - the int identifier of the type of message being logged.

close

public abstract void close()
                    throws LogException
Closes this log.

Throws:
LogException - if this log failed to close for any reason.