casacore
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | List of all members
casacore::LogSinkInterface Class Referenceabstract

More...

#include <LogSinkInterface.h>

Public Member Functions

 LogSinkInterface ()
 Create with a NORMAL filter. More...
 
 LogSinkInterface (const LogFilterInterface &filter)
 Create with the supplied filter. More...
 
 LogSinkInterface (const LogSinkInterface &other)
 Copy semantics - copy the filter from other to this More...
 
LogSinkInterfaceoperator= (const LogSinkInterface &)
 
virtual ~LogSinkInterface ()
 
virtual const LogFilterInterfacefilter () const
 Get/set the filter. More...
 
virtual LogSinkInterfacefilter (const LogFilterInterface &filter)
 
virtual uInt nelements () const
 Get number of messages in sink. More...
 
virtual Double getTime (uInt i) const
 Get given part of the i-th message from the sink. More...
 
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
 This function must be over-ridden in derived classes. More...
 
virtual void flush (Bool global=True)
 Write any pending output. More...
 
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. More...
 
virtual void clearLocally ()
 Clear the local sink (i.e. More...
 
virtual String id () const =0
 Returns the id of the LogSink in use... More...
 
virtual void cerrToo (bool cerr2)
 Write to cerr too. More...
 
void setTaskName (const String &theTask)
 

Static Public Member Functions

static String localId ()
 Returns the id for this class... More...
 

Protected Attributes

String taskName
 

Private Attributes

LogFilterInterfacefilter_p
 

Detailed Description

Accepts LogMessages and posts them to some destination

Intended use:

Internal

Review Status

Reviewed By:
wbrouw
Date Reviewed:
1996/08/21
Test programs:
tLogging
Demo programs:
dLogging

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) {
}
@ DEBUGGING
Low priority - primarily used for findding problems or tracing execution.
Definition: LogMessage.h:108
LogSinkInterface()
Create with a NORMAL filter.

For a more complete example see (see (file="Logging.h"))Logging.h.

Motivation

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

To Do

Definition at line 99 of file LogSinkInterface.h.

Constructor & Destructor Documentation

◆ LogSinkInterface() [1/3]

casacore::LogSinkInterface::LogSinkInterface ( )

Create with a NORMAL filter.

◆ LogSinkInterface() [2/3]

casacore::LogSinkInterface::LogSinkInterface ( const LogFilterInterface filter)

Create with the supplied filter.

◆ LogSinkInterface() [3/3]

casacore::LogSinkInterface::LogSinkInterface ( const LogSinkInterface other)

Copy semantics - copy the filter from other to this

◆ ~LogSinkInterface()

virtual casacore::LogSinkInterface::~LogSinkInterface ( )
virtual

Member Function Documentation

◆ cerrToo()

virtual void casacore::LogSinkInterface::cerrToo ( bool  cerr2)
virtual

Write to cerr too.

◆ clearLocally()

virtual void casacore::LogSinkInterface::clearLocally ( )
virtual

Clear the local sink (i.e.

remove all messages from it). The default implementation does nothing.

Reimplemented in casacore::TableLogSink, casacore::MemoryLogSink, and casacore::LogSink.

◆ filter() [1/2]

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

Get/set the filter.

Reimplemented in casacore::LogSink.

Referenced by casacore::TableLogSink::makeSink().

◆ filter() [2/2]

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

Reimplemented in casacore::LogSink.

◆ flush()

virtual void casacore::LogSinkInterface::flush ( Bool  global = True)
virtual

Write any pending output.

Reimplemented in casacore::TableLogSink, casacore::StreamLogSink, and casacore::LogSink.

◆ getLocation()

virtual String casacore::LogSinkInterface::getLocation ( uInt  i) const
virtual

◆ getMessage()

virtual String casacore::LogSinkInterface::getMessage ( uInt  i) const
virtual

◆ getObjectID()

virtual String casacore::LogSinkInterface::getObjectID ( uInt  i) const
virtual

◆ getPriority()

virtual String casacore::LogSinkInterface::getPriority ( uInt  i) const
virtual

◆ getTime()

virtual Double casacore::LogSinkInterface::getTime ( uInt  i) const
virtual

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

Reimplemented in casacore::TableLogSink, casacore::MemoryLogSink, and casacore::LogSink.

◆ id()

virtual String casacore::LogSinkInterface::id ( ) const
pure virtual

◆ localId()

static String casacore::LogSinkInterface::localId ( )
static

Returns the id for this class...

◆ nelements()

virtual uInt casacore::LogSinkInterface::nelements ( ) const
virtual

Get number of messages in sink.

Reimplemented in casacore::TableLogSink, casacore::MemoryLogSink, and casacore::LogSink.

◆ operator=()

LogSinkInterface& casacore::LogSinkInterface::operator= ( const LogSinkInterface )

◆ postLocally()

virtual Bool casacore::LogSinkInterface::postLocally ( const LogMessage message)
pure virtual

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.

Implemented in casacore::TableLogSink, casacore::StreamLogSink, casacore::NullLogSink, casacore::MemoryLogSink, and casacore::LogSink.

◆ setTaskName()

void casacore::LogSinkInterface::setTaskName ( const String theTask)
inline

Definition at line 157 of file LogSinkInterface.h.

References taskName.

◆ writeLocally()

virtual void casacore::LogSinkInterface::writeLocally ( Double  time,
const String message,
const String priority,
const String location,
const String objectID 
)
virtual

Write a message (usually from another logsink) into the local one.

The default implementation does nothing.

Reimplemented in casacore::TableLogSink, casacore::MemoryLogSink, and casacore::LogSink.

Member Data Documentation

◆ filter_p

LogFilterInterface* casacore::LogSinkInterface::filter_p
private

Definition at line 159 of file LogSinkInterface.h.

◆ taskName

String casacore::LogSinkInterface::taskName
protected

Definition at line 161 of file LogSinkInterface.h.

Referenced by setTaskName().


The documentation for this class was generated from the following file: