Loading...
Searching...
No Matches
casacore::TableLogSink Class Reference
tables package (libcasa_tables) » LogTables_module

More...

`#include <TableLogSink.h>`

## 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.
TableLogSink & | operator= (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 Table & | table () const
| Access to the actual log table and its columns.
Table & | table ()
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.
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.
Public Member Functions inherited from casacore::LogSinkInterface
| LogSinkInterface ()
| Create with a NORMAL filter.
| LogSinkInterface (const LogFilterInterface &filter)
| Create with the supplied filter.
| LogSinkInterface (const LogSinkInterface &other)
| Copy semantics - copy the filter from other to this.
LogSinkInterface & | operator= (const LogSinkInterface &)
virtual | ~LogSinkInterface ()
virtual const LogFilterInterface & | filter () const
| Get/set the filter.
virtual LogSinkInterface & | filter (const LogFilterInterface &filter)
virtual void | cerrToo (bool cerr2)
| Write to cerr too.
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.
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)
Static Public Member Functions inherited from casacore::LogSinkInterface
static String | localId ()
| Returns the id for this class...

## Private Member Functions

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
ScalarColumn< Double > | time_p
ScalarColumn< String > | priority_p
ScalarColumn< String > | message_p
ScalarColumn< String > | location_p
| Origin.
ScalarColumn< String > | id_p
| ObjectID.

## 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

- LogSinkInterface
- Tables

### 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

- Allow a subset of the columns to be written? e.g., only time, message, and priority.
- Allow time sorting in concatenate?

Definition at line 89 of file TableLogSink.h.

## Member Enumeration Documentation

## Columns

enum casacore::TableLogSink::Columns

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 157 of file TableLogSink.h.

## Constructor & Destructor Documentation

## TableLogSink() [1/4]

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

References casacore::LogSinkInterface::filter().

Referenced by copy_other(), operator=(), and TableLogSink().

## TableLogSink() [2/4]

casacore::TableLogSink::TableLogSink | ( | const LogFilterInterface & | filter,
|  | const String & | fileName )

References casacore::LogSinkInterface::filter().

## TableLogSink() [3/4]

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.

## TableLogSink() [4/4]

casacore::TableLogSink::TableLogSink | ( | const TableLogSink & | other | ) |

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

References TableLogSink().

## ~TableLogSink()

casacore::TableLogSink::~TableLogSink | ( |  | ) |

## Member Function Documentation

## attachCols()

void casacore::TableLogSink::attachCols | ( |  | ) |

private

Attach the column objects and create unit keywor if needed.

## clearLocally()

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

virtual

Clear the local sink (i.e.

remove all messages from it).

Reimplemented from casacore::LogSinkInterface.

## columnName()

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

static

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

## copy_other()

void casacore::TableLogSink::copy_other | ( | const TableLogSink & | other | ) |

private

Avoid duplicating code in copy ctor and assignment operator.

References TableLogSink().

## flush()

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

virtual

Write out any pending output to the table.

Reimplemented from casacore::LogSinkInterface.

References casacore::True.

## getLocation()

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

virtual

Reimplemented from casacore::LogSinkInterface.

## getMessage()

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

virtual

Reimplemented from casacore::LogSinkInterface.

## getObjectID()

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

virtual

Reimplemented from casacore::LogSinkInterface.

## getPriority()

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

virtual

Reimplemented from casacore::LogSinkInterface.

## getTime()

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

virtual

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

Reimplemented from casacore::LogSinkInterface.

## id()

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

virtual

Returns the id of the LogSink in use.

Implements casacore::LogSinkInterface.

References casacore::LogSinkInterface::filter().

## init()

void casacore::TableLogSink::init | ( | const String & | fileName | ) |

private

Initialize the object.

## localId()

String casacore::TableLogSink::localId | ( |  | ) |

static

Returns the id for this class.

## location()

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

inline

Definition at line 243 of file TableLogSink.h.

References location_p.

Referenced by writeLocally().

## logTableDescription()

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).

## makeSink() [1/3]

LogSink casacore::TableLogSink::makeSink | ( | const LogFilterInterface & | filter,
|  | const String & | fileName )

static

References casacore::LogSinkInterface::filter().

## makeSink() [2/3]

LogSink casacore::TableLogSink::makeSink | ( | const String & | fileName | ) |

inline static

Make a LogSink for a TableLogSink with a new table.

Default filter is NORMAL.

Definition at line 254 of file TableLogSink.h.

References makeSink().

Referenced by makeSink(), and makeSink().

## makeSink() [3/3]

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

inline static

Definition at line 256 of file TableLogSink.h.

References casacore::LogSinkInterface::filter(), and makeSink().

## makeTable()

void casacore::TableLogSink::makeTable | ( | SetupNewTable & |  | ) |

private

Make a new log table.

## message()

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

inline

Definition at line 251 of file TableLogSink.h.

References message_p.

Referenced by postLocally(), and writeLocally().

## nelements()

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

virtual

Get number of messages in sink.

Reimplemented from casacore::LogSinkInterface.

## objectID()

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

inline

Definition at line 247 of file TableLogSink.h.

References id_p.

Referenced by writeLocally().

## operator=()

TableLogSink & casacore::TableLogSink::operator= | ( | const TableLogSink & | other | ) |

References TableLogSink().

## postLocally()

virtual Bool casacore::TableLogSink::postLocally | ( | const LogMessage & | message | ) |

virtual

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

Implements casacore::LogSinkInterface.

References message().

## priority()

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

inline

Definition at line 239 of file TableLogSink.h.

References priority_p.

Referenced by writeLocally().

## reopenRW()

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.

References casacore::LogSinkInterface::filter().

## roLocation()

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

inline

Definition at line 241 of file TableLogSink.h.

References location_p.

## roMessage()

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

inline

Definition at line 249 of file TableLogSink.h.

References message_p.

## roObjectID()

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

inline

Definition at line 245 of file TableLogSink.h.

References id_p.

## roPriority()

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

inline

Definition at line 237 of file TableLogSink.h.

References priority_p.

## roTime()

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

inline

Definition at line 233 of file TableLogSink.h.

References time_p.

## table() [1/2]

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

inline

Definition at line 231 of file TableLogSink.h.

References log_table_p.

## table() [2/2]

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 230 of file TableLogSink.h.

References log_table_p.

## time()

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

inline

Definition at line 235 of file TableLogSink.h.

References time_p.

Referenced by writeLocally().

## writeLocally()

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.

References location(), message(), objectID(), priority(), and time().

## Member Data Documentation

## id_p

ScalarColumn<String> casacore::TableLogSink::id_p

private

ObjectID.

Definition at line 226 of file TableLogSink.h.

Referenced by objectID(), and roObjectID().

## location_p

ScalarColumn<String> casacore::TableLogSink::location_p

private

Origin.

Definition at line 224 of file TableLogSink.h.

Referenced by location(), and roLocation().

## log_table_p

Table casacore::TableLogSink::log_table_p

private

Definition at line 219 of file TableLogSink.h.

Referenced by table(), and table().

## message_p

ScalarColumn<String> casacore::TableLogSink::message_p

private

Definition at line 222 of file TableLogSink.h.

Referenced by message(), and roMessage().

## priority_p

ScalarColumn<String> casacore::TableLogSink::priority_p

private

Definition at line 221 of file TableLogSink.h.

Referenced by priority(), and roPriority().

## time_p

ScalarColumn<Double> casacore::TableLogSink::time_p

private

Definition at line 220 of file TableLogSink.h.

Referenced by roTime(), and time().

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

- tables/LogTables/TableLogSink.h