GlishLogSink.h

Classes

GlishLogSink -- Send log messages as Glish events. (full description)

class GlishLogSink : public LogSinkInterface

Interface

Public Members
GlishLogSink(LogMessage::Priority filter, CountedPtr<CountedPtr> eventSource)
GlishLogSink(const LogFilterInterface &filter, CountedPtr<CountedPtr> eventSource)
GlishLogSink(const GlishLogSink &other)
GlishLogSink &operator=(const GlishLogSink &other)
virtual Bool postLocally(const LogMessage &message)
static String localId( )
String id( ) const
Private Members
GlishLogSink()

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

This log sink is used to post log messages to the Glish bus. While this has been implemented for the use of the AIPS++ Tasking system, it is independent of the Tasking system. If the current process is not connected to the Glish bus the messages is posted to cerr instead.

On the assumption that log messages will be sent between the process and the user interface fairly often, the memory use of the current process tags along in the record.

The posted Glish event is named log and is a record with the following format:

Field (type)

Contents

nessage (string)

The posted message.

time_mjd (double)

The time the message was created, MJD in days. Does not take into account the timezone.

time_string (string)

Formatted version of the time, including the timezone.

location (string)

Source code origin of the message. May contain all of function, file, and line number. Does not contain the ObjectID.

id (record)

ObjectID of the message originator, in the record format defined by ObjectID::toRecord().

_memory (double)

Memory use of this process, in MB.

In general, you do not need to set up GlishLogSink yourself, the Tasking system will use it for you. However if you have a nonstandard client from which you wish to post log messages in the standard format on the Glish bus, you merely have to replace the global sink with a GlishLogSink.

Example

If you wanted to setup a non-tasking executable to log messages in the standard way to the glish bus so the log window and log table will behave normally for the user, you can do so as follows:
    int main(int argc, char **argv)
    {
       CountedPtr<GlishSysEventSource> ptr(new GlishSysEventSource(argc, argv));
       LogFilter defaultFilter;
       LogSinkInterface *newGlobal = new GlishLogSink(defaultFilter, ptr);
       LogSink::globalSink(newGlobal);
       ...
       LogIO io;
       io << "Every good boy deserves fudge" << LogIO::POST; // goes to Glish!
       ...
    

Motivation

Used by the tasking system to send log messages over the glish bus, where they are caught and displayed by the users glish session, and (also) sent to a client which saves them in a log table.

To Do

Member Description

GlishLogSink(LogMessage::Priority filter, CountedPtr<CountedPtr> eventSource)
GlishLogSink(const LogFilterInterface &filter, CountedPtr<CountedPtr> eventSource)

Construct the log sink with the supplied filter and GlishSysEventSource. If the pointer to the event source is null, or if it becomes disconnected, log messages will be posted to cerr.

GlishLogSink(const GlishLogSink &other)
GlishLogSink &operator=(const GlishLogSink &other)

Reference semantics, i.e. after copying posted messages to either GlishLogSink will be posted to the same Glish bus.

virtual Bool postLocally(const LogMessage &message)

Post the message to the glish bus if we are connected to Glish, otherwise post the message to cerr.

static String localId( )

Returns the id for this class...

String id( ) const

Returns the id of the LogSink in use...

GlishLogSink()

Undefined and inaccessible