LogSinkInterface.h

Classes

LogSinkInterface -- Accepts LogMessages and posts them to some destination (full description)

class LogSinkInterface

Interface

Public Members
LogSinkInterface()
LogSinkInterface(const LogFilterInterface &filter)
LogSinkInterface(const LogSinkInterface &other)
LogSinkInterface &operator=(const LogSinkInterface &)
virtual ~LogSinkInterface()
virtual const LogFilterInterface &filter() const
virtual LogSinkInterface &filter(const LogFilterInterface &filter)
virtual uInt nelements() const
virtual Double getTime (uInt i) const
virtual String getPriority (uInt i) const
virtual String getMessage (uInt i) const
virtual String getLocation (uInt i) const
virtual String getObjectID (uInt i) const
virtual Bool postLocally(const LogMessage &message)= 0
virtual void flush (Bool global=True)
virtual void writeLocally (Double time, const String& message, const String& priority, const String& location, const String& objectID)
virtual void clearLocally()
static String localId( )
virtual String id( ) const = 0

Description

Review Status

Reviewed By:
wbrouw
Date Reviewed:
1996/08/21
Programs:
Demos:
Tests:

Prerequisite

Etymology

Log as in "Log Book." Sink from its common usage ("source/sink") as a thing which can accept some substance or energy. Interface because this is an abstract, not concrete, class.

Synopsis

This abstract base class is not intended for applications programmers. Instead they should look at LogSink.

This class defines a minimal "posting" interface for all objects which accept log messages. The fundamental model of a LogSinkInterface is:

  1. That it contains a LogFilterInterface that is used to accept or reject messages; and
  2. That it has a post message that takes a log message; and, if it passes the filter, does something with it (prints it to a stream, saves it to a table, ...).
There is no notion of local vs global sinks - that is imposed by LogSink.

Example

    LogSinkInterface &ref = ...;
    LogMessage message(...);
    ref.postLocally(message);
    if (ref.filter().lowestPriority() != LogMessage::DEBUGGING) {
       ref.filter(LogMessage::DEBUGGING);
    }
    
For a more complete example see Logging.h.

Motivation

Make it straightforward to extend the number of places a message may be in the future through derivation.

To Do

Member Description

LogSinkInterface()

Create with a NORMAL filter.

LogSinkInterface(const LogFilterInterface &filter)

Create with the supplied filter.

LogSinkInterface(const LogSinkInterface &other)
LogSinkInterface &operator=(const LogSinkInterface &)

Copy semantics - copy the filter from other to this

virtual ~LogSinkInterface()

virtual const LogFilterInterface &filter() const
virtual LogSinkInterface &filter(const LogFilterInterface &filter)

Get/set the filter.

virtual uInt nelements() const

Get number of messages in sink.

virtual Double getTime (uInt i) const
virtual String getPriority (uInt i) const
virtual String getMessage (uInt i) const
virtual String getLocation (uInt i) const
virtual String getObjectID (uInt i) const

Get given part of the i-th message from the sink.

virtual Bool postLocally(const LogMessage &message)= 0

This function must be over-ridden in derived classes. If the filter passes the message, do what is necessary with the message and return True.

virtual void flush (Bool global=True)

Write any pending output.

virtual void writeLocally (Double time, const String& message, const String& priority, const String& location, const String& objectID)

Write a message (usually from another logsink) into the local one. The default implementation does nothing.

virtual void clearLocally()

Clear the local sink (i.e. remove all messages from it). The default implementation does nothing.

static String localId( )

Returns the id for this class...

virtual String id( ) const = 0

Returns the id of the LogSink in use...