casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::TableLogSink Class Reference

Save log messages in a Casacore Table. More...

#include <TableLogSink.h>

Inheritance diagram for casacore::TableLogSink:
casacore::LogSinkInterface

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. More...
 
 TableLogSink (const LogFilterInterface &filter, const String &fileName)
 
 TableLogSink (const String &fileName)
 Open the log table for readonly. More...
 
 TableLogSink (const TableLogSink &other)
 After copying, both sinks will write to the same Table. More...
 
TableLogSinkoperator= (const TableLogSink &other)
 
 ~TableLogSink ()
 
void reopenRW (const LogFilterInterface &filter)
 Reopen the logtable for read/write (if needed). More...
 
virtual Bool postLocally (const LogMessage &message)
 If the message passes the filter, write it to the log table. More...
 
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
 
const Tabletable () const
 Access to the actual log table and its columns. More...
 
Tabletable ()
 
const ScalarColumn< Double > & roTime () const
 
ScalarColumn< Double > & time ()
 
const ScalarColumn< String > & roPriority () const
 
ScalarColumn< String > & priority ()
 
const ScalarColumn< String > & roMessage () const
 
ScalarColumn< String > & message ()
 
const ScalarColumn< String > & roLocation () const
 
ScalarColumn< String > & location ()
 
const ScalarColumn< String > & roObjectID () const
 
ScalarColumn< String > & objectID ()
 
virtual void flush (Bool global=True)
 Write out any pending output to the table. 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...
 
String id () const
 Returns the id of the LogSink in use... More...
 
- Public Member Functions inherited from casacore::LogSinkInterface
 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 void cerrToo (bool cerr2)
 Write to cerr too. More...
 
void setTaskName (const String &theTask)
 

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. More...
 
static TableDesc logTableDescription ()
 Description of the log table. More...
 
static String localId ()
 Returns the id for this class... More...
 
static LogSink makeSink (const String &fileName)
 Make a LogSink for a TableLogSink with a new table. More...
 
static LogSink makeSink (LogMessage::Priority filter, const String &fileName)
 
static LogSink makeSink (const LogFilterInterface &filter, const String &fileName)
 
- Static Public Member Functions inherited from casacore::LogSinkInterface
static String localId ()
 Returns the id for this class... More...
 

Private Member Functions

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

Private Attributes

Table log_table_p
 
ScalarColumn< Doubletime_p
 
ScalarColumn< Stringpriority_p
 
ScalarColumn< Stringmessage_p
 
ScalarColumn< Stringlocation_p
 Origin. More...
 
ScalarColumn< Stringid_p
 ObjectID. More...
 

Additional Inherited Members

- Protected Attributes inherited from casacore::LogSinkInterface
String taskName
 

Detailed Description

Save log messages in a Casacore 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 a Casacore 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 a Casacore 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

casacore::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().

casacore::TableLogSink::TableLogSink ( const LogFilterInterface filter,
const String fileName 
)
casacore::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.

casacore::TableLogSink::TableLogSink ( const TableLogSink other)

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

casacore::TableLogSink::~TableLogSink ( )
casacore::TableLogSink::TableLogSink ( )
private

Undefined and inaccessible.

Member Function Documentation

void casacore::TableLogSink::attachCols ( )
private

Attach the column objects and create unit keywor if needed.

virtual void casacore::TableLogSink::clearLocally ( )
virtual

Clear the local sink (i.e.

remove all messages from it).

Reimplemented from casacore::LogSinkInterface.

static String casacore::TableLogSink::columnName ( Columns  which)
static

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

void casacore::TableLogSink::copy_other ( const TableLogSink other)
private

Avoid duplicating code in copy ctor and assignment operator.

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

Write out any pending output to the table.

Reimplemented from casacore::LogSinkInterface.

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

Reimplemented from casacore::LogSinkInterface.

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

Reimplemented from casacore::LogSinkInterface.

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

Reimplemented from casacore::LogSinkInterface.

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

Reimplemented from casacore::LogSinkInterface.

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

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

Reimplemented from casacore::LogSinkInterface.

String casacore::TableLogSink::id ( ) const
virtual

Returns the id of the LogSink in use...

Implements casacore::LogSinkInterface.

void casacore::TableLogSink::init ( const String fileName)
private

Initialize the object.

static String casacore::TableLogSink::localId ( )
static

Returns the id for this class...

ScalarColumn< String > & casacore::TableLogSink::location ( )
inline

Definition at line 248 of file TableLogSink.h.

References location_p.

static TableDesc casacore::TableLogSink::logTableDescription ( )
static

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 casacore::TableLogSink::makeSink ( const String fileName)
inlinestatic

Make a LogSink for a TableLogSink with a new table.

Default filter is NORMAL.

Definition at line 259 of file TableLogSink.h.

Referenced by makeSink().

LogSink casacore::TableLogSink::makeSink ( LogMessage::Priority  filter,
const String fileName 
)
inlinestatic

Definition at line 261 of file TableLogSink.h.

References makeSink().

static LogSink casacore::TableLogSink::makeSink ( const LogFilterInterface filter,
const String fileName 
)
static
void casacore::TableLogSink::makeTable ( SetupNewTable )
private

Make a new log table.

ScalarColumn< String > & casacore::TableLogSink::message ( )
inline

Definition at line 256 of file TableLogSink.h.

References message_p.

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

Get number of messages in sink.

Reimplemented from casacore::LogSinkInterface.

ScalarColumn< String > & casacore::TableLogSink::objectID ( )
inline

Definition at line 252 of file TableLogSink.h.

References id_p.

TableLogSink& casacore::TableLogSink::operator= ( const TableLogSink other)
virtual Bool casacore::TableLogSink::postLocally ( const LogMessage message)
virtual

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

Implements casacore::LogSinkInterface.

ScalarColumn< String > & casacore::TableLogSink::priority ( )
inline

Definition at line 244 of file TableLogSink.h.

References priority_p.

void casacore::TableLogSink::reopenRW ( const LogFilterInterface filter)

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

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

const ScalarColumn< String > & casacore::TableLogSink::roLocation ( ) const
inline

Definition at line 246 of file TableLogSink.h.

References location_p.

const ScalarColumn< String > & casacore::TableLogSink::roMessage ( ) const
inline

Definition at line 254 of file TableLogSink.h.

References message_p.

const ScalarColumn< String > & casacore::TableLogSink::roObjectID ( ) const
inline

Definition at line 250 of file TableLogSink.h.

References id_p.

const ScalarColumn< String > & casacore::TableLogSink::roPriority ( ) const
inline

Definition at line 242 of file TableLogSink.h.

References priority_p.

const ScalarColumn< Double > & casacore::TableLogSink::roTime ( ) const
inline

Definition at line 238 of file TableLogSink.h.

References time_p.

const Table & casacore::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 235 of file TableLogSink.h.

References log_table_p.

Table & casacore::TableLogSink::table ( )
inline

Definition at line 236 of file TableLogSink.h.

References log_table_p.

ScalarColumn< Double > & casacore::TableLogSink::time ( )
inline

Definition at line 240 of file TableLogSink.h.

References time_p.

virtual void casacore::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 casacore::LogSinkInterface.

Member Data Documentation

ScalarColumn<String> casacore::TableLogSink::id_p
private

ObjectID.

Definition at line 231 of file TableLogSink.h.

Referenced by objectID(), and roObjectID().

ScalarColumn<String> casacore::TableLogSink::location_p
private

Origin.

Definition at line 229 of file TableLogSink.h.

Referenced by location(), and roLocation().

Table casacore::TableLogSink::log_table_p
private

Definition at line 224 of file TableLogSink.h.

Referenced by table().

ScalarColumn<String> casacore::TableLogSink::message_p
private

Definition at line 227 of file TableLogSink.h.

Referenced by message(), and roMessage().

ScalarColumn<String> casacore::TableLogSink::priority_p
private

Definition at line 226 of file TableLogSink.h.

Referenced by priority(), and roPriority().

ScalarColumn<Double> casacore::TableLogSink::time_p
private

Definition at line 225 of file TableLogSink.h.

Referenced by roTime(), and time().


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