casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
casa::TableLogSink Class Reference

Save log messages in an AIPS++ Table. More...

#include <TableLogSink.h>

Inheritance diagram for casa::TableLogSink:
casa::LogSinkInterface

List of all members.

Public Types

enum  Columns {
  TIME,
  PRIORITY,
  MESSAGE,
  LOCATION,
  OBJECT_ID
}
 Defines the minimal set of columns in the table (more may exist, but are ignored. More...

Public Member Functions

 TableLogSink (LogMessage::Priority filter, const String &fileName)
 If fileName exists, attach and append to it, otherwise create a table with that name.
 TableLogSink (const LogFilterInterface &filter, const String &fileName)
 TableLogSink (const String &fileName)
 Open the log table for readonly.
 TableLogSink (const TableLogSink &other)
 After copying, both sinks will write to the same Table.
TableLogSinkoperator= (const TableLogSink &other)
 ~TableLogSink ()
 
   

void reopenRW (const LogFilterInterface &filter)
 Reopen the logtable for read/write (if needed).
virtual Bool postLocally (const LogMessage &message)
 If the message passes the filter, write it to the log table.
virtual uInt nelements () const
 Get number of messages in sink.
virtual Double getTime (uInt i) const
 Get given part of the i-th message from the sink.
virtual String getPriority (uInt i) const
virtual String getMessage (uInt i) const
virtual String getLocation (uInt i) const
virtual String getObjectID (uInt i) const
const Tabletable () const
 Access to the actual log table and its columns.
Tabletable ()
const ROScalarColumn< Double > & roTime () const
ScalarColumn< Double > & time ()
const ROScalarColumn< String > & roPriority () const
ScalarColumn< String > & priority ()
const ROScalarColumn< String > & roMessage () const
ScalarColumn< String > & message ()
const ROScalarColumn< String > & roLocation () const
ScalarColumn< String > & location ()
const ROScalarColumn< String > & roObjectID () const
ScalarColumn< String > & objectID ()
virtual void flush (Bool global=True)
 Write out any pending output to the table.
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.
virtual void clearLocally ()
 Clear the local sink (i.e.
String id () const
 Returns the id of the LogSink in use...

Static Public Member Functions

static String columnName (Columns which)
 Turn the Columns enum into a String which is the actual column name in the Table.
static TableDesc logTableDescription ()
 Description of the log table.
static String localId ()
 Returns the id for this class...
static LogSink makeSink (const String &fileName)
 Make a LogSink for a TableLogSink with a new table.
static LogSink makeSink (LogMessage::Priority filter, const String &fileName)
static LogSink makeSink (const LogFilterInterface &filter, const String &fileName)

Private Member Functions

 TableLogSink ()
 
   

void copy_other (const TableLogSink &other)
 Avoid duplicating code in copy ctor and assignment operator.
void makeTable (SetupNewTable &)
 Make a new log table.
void attachCols ()
 Attach the column objects and create unit keywor if needed.
void init (const String &fileName)
 Initialize the object.

Private Attributes

Table log_table_p
ROScalarColumn< DoubleroTime_p
 Message.
ROScalarColumn< StringroPriority_p
ROScalarColumn< StringroMessage_p
ROScalarColumn< StringroLocation_p
 Origin.
ROScalarColumn< StringroId_p
 ObjectID.
ScalarColumn< Doubletime_p
ScalarColumn< Stringpriority_p
ScalarColumn< Stringmessage_p
ScalarColumn< Stringlocation_p
 Origin.
ScalarColumn< Stringid_p
 ObjectID.

Detailed Description

Save log messages in an AIPS++ Table.

Intended use:

Public interface

Review Status

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

Prerequisite

Etymology

Log to an AIPS++ Table.

Synopsis

Unlike the other classes derived from LogSinkInterface , there are utility functions in this class which might be of some modest interest. In particular, the member functions which define the structure of the table and define the column names might be of interest.

This class posts messages which pass the filter to an AIPS++ Table . It puts every field of the LogMessage into its own column.

Example

See (see (file="Logging.h"))Logging.h .

Motivation

"Persistent" log messages must be stored in a Table.

To Do

Definition at line 92 of file TableLogSink.h.


Member Enumeration Documentation

Defines the minimal set of columns in the table (more may exist, but are ignored.

Enumerator:
TIME 

MJD in seconds, UT.

(Double.)

PRIORITY 

Message importance.

(String).

MESSAGE 

Informational message.

(String).

LOCATION 

Source code origin of the log message.

Usually a combination of class name, method name, file name and line number, but any String is legal.

OBJECT_ID 

ObjectID of distributed object that created the message (String).

If empty, no OBJECT_ID was set.

Definition at line 160 of file TableLogSink.h.


Constructor & Destructor Documentation

casa::TableLogSink::TableLogSink ( LogMessage::Priority  filter,
const String fileName 
)

If fileName exists, attach and append to it, otherwise create a table with that name.

If the table exists, it must have all the required columns defined by logTableDescription().

casa::TableLogSink::TableLogSink ( const LogFilterInterface filter,
const String fileName 
)
casa::TableLogSink::TableLogSink ( const String fileName) [explicit]

Open the log table for readonly.

If needed, reopenRW can be used later to define a filter and to open the logtable for writing.

After copying, both sinks will write to the same Table.

   

   

Undefined and inaccessible


Member Function Documentation

void casa::TableLogSink::attachCols ( ) [private]

Attach the column objects and create unit keywor if needed.

virtual void casa::TableLogSink::clearLocally ( ) [virtual]

Clear the local sink (i.e.

remove all messages from it).

Reimplemented from casa::LogSinkInterface.

static String casa::TableLogSink::columnName ( Columns  which) [static]

Turn the Columns enum into a String which is the actual column name in the Table.

void casa::TableLogSink::copy_other ( const TableLogSink other) [private]

Avoid duplicating code in copy ctor and assignment operator.

virtual void casa::TableLogSink::flush ( Bool  global = True) [virtual]

Write out any pending output to the table.

Reimplemented from casa::LogSinkInterface.

virtual String casa::TableLogSink::getLocation ( uInt  i) const [virtual]

Reimplemented from casa::LogSinkInterface.

virtual String casa::TableLogSink::getMessage ( uInt  i) const [virtual]

Reimplemented from casa::LogSinkInterface.

virtual String casa::TableLogSink::getObjectID ( uInt  i) const [virtual]

Reimplemented from casa::LogSinkInterface.

virtual String casa::TableLogSink::getPriority ( uInt  i) const [virtual]

Reimplemented from casa::LogSinkInterface.

virtual Double casa::TableLogSink::getTime ( uInt  i) const [virtual]

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

Reimplemented from casa::LogSinkInterface.

String casa::TableLogSink::id ( ) const [virtual]

Returns the id of the LogSink in use...

Implements casa::LogSinkInterface.

void casa::TableLogSink::init ( const String fileName) [private]

Initialize the object.

static String casa::TableLogSink::localId ( ) [static]

Returns the id for this class...

Reimplemented from casa::LogSinkInterface.

Definition at line 256 of file TableLogSink.h.

References DebugAssert, casa::TableColumn::isNull(), and location_p.

Description of the log table.

You can use this if, e.g., you do not want to use the storage managers that this class creates by default (currently Miriad).

LogSink casa::TableLogSink::makeSink ( const String fileName) [inline, static]

Make a LogSink for a TableLogSink with a new table.

Default filter is NORMAL.

Definition at line 267 of file TableLogSink.h.

Referenced by makeSink().

LogSink casa::TableLogSink::makeSink ( LogMessage::Priority  filter,
const String fileName 
) [inline, static]

Definition at line 269 of file TableLogSink.h.

References makeSink().

static LogSink casa::TableLogSink::makeSink ( const LogFilterInterface filter,
const String fileName 
) [static]

Make a new log table.

Definition at line 264 of file TableLogSink.h.

References DebugAssert, casa::TableColumn::isNull(), and message_p.

virtual uInt casa::TableLogSink::nelements ( ) const [virtual]

Get number of messages in sink.

Reimplemented from casa::LogSinkInterface.

Definition at line 260 of file TableLogSink.h.

References DebugAssert, id_p, and casa::TableColumn::isNull().

TableLogSink& casa::TableLogSink::operator= ( const TableLogSink other)
virtual Bool casa::TableLogSink::postLocally ( const LogMessage message) [virtual]

If the message passes the filter, write it to the log table.

Implements casa::LogSinkInterface.

Definition at line 252 of file TableLogSink.h.

References DebugAssert, casa::TableColumn::isNull(), and priority_p.

Reopen the logtable for read/write (if needed).

When it actually reopens, the given filter will be used.

const ROScalarColumn< String > & casa::TableLogSink::roLocation ( ) const [inline]

Definition at line 254 of file TableLogSink.h.

References roLocation_p.

const ROScalarColumn< String > & casa::TableLogSink::roMessage ( ) const [inline]

Definition at line 262 of file TableLogSink.h.

References roMessage_p.

const ROScalarColumn< String > & casa::TableLogSink::roObjectID ( ) const [inline]

Definition at line 258 of file TableLogSink.h.

References roId_p.

const ROScalarColumn< String > & casa::TableLogSink::roPriority ( ) const [inline]

Definition at line 250 of file TableLogSink.h.

References roPriority_p.

const ROScalarColumn< Double > & casa::TableLogSink::roTime ( ) const [inline]

Definition at line 246 of file TableLogSink.h.

References roTime_p.

const Table & casa::TableLogSink::table ( ) const [inline]

Access to the actual log table and its columns.


Caution: Functions time, priority, message, location, objectID return a null ScalarColumn object when the logtable is not writable; Using it may result in using a null pointer causing a core dump; In debug mode it is checked if the object is not null;

Definition at line 243 of file TableLogSink.h.

References log_table_p.

Definition at line 244 of file TableLogSink.h.

References log_table_p.

Definition at line 248 of file TableLogSink.h.

References DebugAssert, casa::TableColumn::isNull(), and time_p.

virtual void casa::TableLogSink::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.

Reimplemented from casa::LogSinkInterface.


Member Data Documentation

ObjectID.

Definition at line 239 of file TableLogSink.h.

Referenced by objectID().

Origin.

Definition at line 237 of file TableLogSink.h.

Referenced by location().

Definition at line 224 of file TableLogSink.h.

Referenced by table().

Definition at line 235 of file TableLogSink.h.

Referenced by message().

Definition at line 234 of file TableLogSink.h.

Referenced by priority().

ObjectID.

Definition at line 232 of file TableLogSink.h.

Referenced by roObjectID().

Origin.

Definition at line 230 of file TableLogSink.h.

Referenced by roLocation().

Definition at line 228 of file TableLogSink.h.

Referenced by roMessage().

Definition at line 227 of file TableLogSink.h.

Referenced by roPriority().

Message.

Definition at line 226 of file TableLogSink.h.

Referenced by roTime().

Definition at line 233 of file TableLogSink.h.

Referenced by time().


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