casacore
|
Save log messages in a Casacore 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. 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... | |
TableLogSink & | operator= (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 Table & | table () const |
Access to the actual log table and its columns. More... | |
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. 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... | |
LogSinkInterface & | operator= (const LogSinkInterface &) |
virtual | ~LogSinkInterface () |
virtual const LogFilterInterface & | filter () const |
Get/set the filter. More... | |
virtual LogSinkInterface & | filter (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< Double > | time_p |
ScalarColumn< String > | priority_p |
ScalarColumn< String > | message_p |
ScalarColumn< String > | location_p |
Origin. More... | |
ScalarColumn< String > | id_p |
ObjectID. More... | |
Additional Inherited Members | |
Protected Attributes inherited from casacore::LogSinkInterface | |
String | taskName |
Save log messages in a Casacore 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 a Casacore 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.
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.
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 | ||
) |
|
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 | ( | ) |
|
private |
Undefined and inaccessible.
|
private |
Attach the column objects and create unit keywor if needed.
|
virtual |
Clear the local sink (i.e.
remove all messages from it).
Reimplemented from casacore::LogSinkInterface.
|
private |
Avoid duplicating code in copy ctor and assignment operator.
Write out any pending output to the table.
Reimplemented from casacore::LogSinkInterface.
Reimplemented from casacore::LogSinkInterface.
Reimplemented from casacore::LogSinkInterface.
Reimplemented from casacore::LogSinkInterface.
Reimplemented from casacore::LogSinkInterface.
Get given part of the i-th message from the sink.
Reimplemented from casacore::LogSinkInterface.
|
virtual |
Returns the id of the LogSink in use...
Implements casacore::LogSinkInterface.
|
private |
Initialize the object.
|
static |
Returns the id for this class...
|
inline |
Definition at line 248 of file TableLogSink.h.
References location_p.
|
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).
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().
|
inlinestatic |
Definition at line 261 of file TableLogSink.h.
References makeSink().
|
static |
|
private |
Make a new log table.
|
inline |
Definition at line 256 of file TableLogSink.h.
References message_p.
|
virtual |
Get number of messages in sink.
Reimplemented from casacore::LogSinkInterface.
|
inline |
Definition at line 252 of file TableLogSink.h.
References id_p.
TableLogSink& casacore::TableLogSink::operator= | ( | const TableLogSink & | other | ) |
|
virtual |
If the message passes the filter, write it to the log table.
Implements casacore::LogSinkInterface.
|
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.
|
inline |
Definition at line 246 of file TableLogSink.h.
References location_p.
|
inline |
Definition at line 254 of file TableLogSink.h.
References message_p.
|
inline |
Definition at line 250 of file TableLogSink.h.
References id_p.
|
inline |
Definition at line 242 of file TableLogSink.h.
References priority_p.
|
inline |
Definition at line 238 of file TableLogSink.h.
References time_p.
|
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.
|
inline |
Definition at line 236 of file TableLogSink.h.
References log_table_p.
|
inline |
Definition at line 240 of file TableLogSink.h.
References time_p.
|
virtual |
Write a message (usually from another logsink) into the local one.
Reimplemented from casacore::LogSinkInterface.
|
private |
Definition at line 231 of file TableLogSink.h.
Referenced by objectID(), and roObjectID().
|
private |
|
private |
Definition at line 224 of file TableLogSink.h.
Referenced by table().
|
private |
Definition at line 227 of file TableLogSink.h.
Referenced by message(), and roMessage().
|
private |
Definition at line 226 of file TableLogSink.h.
Referenced by priority(), and roPriority().
|
private |
Definition at line 225 of file TableLogSink.h.