casa
$Rev:20696$
|
Save log messages in an AIPS++ Table. 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 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< Double > | roTime_p |
Message. | |
ROScalarColumn< String > | roPriority_p |
ROScalarColumn< String > | roMessage_p |
ROScalarColumn< String > | roLocation_p |
Origin. | |
ROScalarColumn< String > | roId_p |
ObjectID. | |
ScalarColumn< Double > | time_p |
ScalarColumn< String > | priority_p |
ScalarColumn< String > | message_p |
ScalarColumn< String > | location_p |
Origin. | |
ScalarColumn< String > | id_p |
ObjectID. |
Save log messages in an AIPS++ Table.
Public interface
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.
See (see (file="Logging.h"))Logging.h .
"Persistent" log messages must be stored in a Table.
Definition at line 92 of file TableLogSink.h.
Defines the minimal set of columns in the table (more may exist, but are ignored.
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.
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.
casa::TableLogSink::TableLogSink | ( | const TableLogSink & | other | ) |
After copying, both sinks will write to the same Table
.
casa::TableLogSink::TableLogSink | ( | ) | [private] |
Undefined and inaccessible
void casa::TableLogSink::attachCols | ( | ) | [private] |
Attach the column objects and create unit keywor if needed.
virtual void casa::TableLogSink::clearLocally | ( | ) | [virtual] |
static String casa::TableLogSink::columnName | ( | Columns | which | ) | [static] |
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.
ScalarColumn< String > & casa::TableLogSink::location | ( | ) | [inline] |
Definition at line 256 of file TableLogSink.h.
References DebugAssert, casa::TableColumn::isNull(), and location_p.
static TableDesc casa::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 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] |
void casa::TableLogSink::makeTable | ( | SetupNewTable & | ) | [private] |
Make a new log table.
ScalarColumn< String > & casa::TableLogSink::message | ( | ) | [inline] |
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.
ScalarColumn< String > & casa::TableLogSink::objectID | ( | ) | [inline] |
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.
ScalarColumn< String > & casa::TableLogSink::priority | ( | ) | [inline] |
Definition at line 252 of file TableLogSink.h.
References DebugAssert, casa::TableColumn::isNull(), and priority_p.
void casa::TableLogSink::reopenRW | ( | const LogFilterInterface & | filter | ) |
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.
Table & casa::TableLogSink::table | ( | ) | [inline] |
Definition at line 244 of file TableLogSink.h.
References log_table_p.
ScalarColumn< Double > & casa::TableLogSink::time | ( | ) | [inline] |
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.
ScalarColumn<String> casa::TableLogSink::id_p [private] |
ScalarColumn<String> casa::TableLogSink::location_p [private] |
Table casa::TableLogSink::log_table_p [private] |
Definition at line 224 of file TableLogSink.h.
Referenced by table().
ScalarColumn<String> casa::TableLogSink::message_p [private] |
Definition at line 235 of file TableLogSink.h.
Referenced by message().
ScalarColumn<String> casa::TableLogSink::priority_p [private] |
Definition at line 234 of file TableLogSink.h.
Referenced by priority().
ROScalarColumn<String> casa::TableLogSink::roId_p [private] |
ROScalarColumn<String> casa::TableLogSink::roLocation_p [private] |
ROScalarColumn<String> casa::TableLogSink::roMessage_p [private] |
Definition at line 228 of file TableLogSink.h.
Referenced by roMessage().
ROScalarColumn<String> casa::TableLogSink::roPriority_p [private] |
Definition at line 227 of file TableLogSink.h.
Referenced by roPriority().
ROScalarColumn<Double> casa::TableLogSink::roTime_p [private] |
ScalarColumn<Double> casa::TableLogSink::time_p [private] |
Definition at line 233 of file TableLogSink.h.
Referenced by time().