#include <LogSink.h>
Inheritance diagram for casa::LogSink:


Part of API
LogMessage can be sent.
Log as in "Log Book." Sink from its common usage ("source/sink") as a thing which can accept some substance or energy.
The LogSink class supplies the destination for LogMessage s. There are two destinations available through the LogSink
post() member function will be called which sends the message to both the global and local destinations, however one or the other may be chosen via LogSink::postGlobally() and postLocally() member functions.
The global sink will normally be set by system library code (it defaults to using cerr. The type of local sink is defined at construction time. Presently you can choose one of:
ostream (typically cerr)
Every LogSink has an attached LogFilterInterface which is used to reject or pass messages. The local and global sinks have their own filters, so they can pass different message priorities (e.g., global DEBUGGING and local NORMAL). Generally applications code shouldn't change the global filter.
LogMessage logMessage(.\..);
LogSink logger(LogMessage::NORMAL, "logtable"); // log locally to a 'logtable'
logMessage.message("this is a message").line(__LINE__);
logger.post(logMessage); // local and global
All possible sinks are derived from an abstract base class: LogSinkInterface . If you want to allow for logging to a different type of sink (i.e. different from a stream or Table) , you first need to derive a new class from LogSinkInterface, and then add a new constructor to LogSink.
LogSink itself contains a reference to the actual object that disposes of the messages. Several LogSink's can share the same actual sink via the copy constructor or assignment operator.
LogSink logger1(LogMessage::NORMAL, "logtable"); LogSink logger2(logger1); // logger2 references logger1 logger2.post(message); // ends up in "logtable"
LogFilterInterface's attached to the different LogSinks.
Logging changes to data and informing users what the software is doing in detail.
Definition at line 138 of file LogSink.h.
| void | postThenThrow (const LogMessage &message) |
Post message and then throw an AipsError exception containing message.toString(). | |
| static void | postGloballyThenThrow (const LogMessage &message) |
Public Member Functions | |
| LogSink (const LogFilterInterface &filter, const CountedPtr< LogSinkInterface > &) | |
| Log to the given sink. | |
| LogSink (const LogFilterInterface &filter, const String &fileName, Int n=0) | |
| Temporary to avoid problem that the bool constructor is taken if a char* is passed. | |
| LogSink (const LogFilterInterface &filter, const Char *fileName, Int n=0) | |
| LogSink (LogMessage::Priority, const String &fileName, Int n=0) | |
| LogSink (LogMessage::Priority, const Char *fileName, Int n=0) | |
| ~LogSink () | |
| Bool | post (const LogMessage &message) |
Send message to both the local and global sink. | |
| virtual Bool | postLocally (const LogMessage &message) |
Send message to the local sink only. | |
| virtual uInt | nelements () const |
| Get number of messages in local sink. | |
| 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. | |
| virtual void | flush (Bool global=True) |
| Write any pending output (by default also the global sink). | |
| String | id () const |
| Returns the id of the LogSink in use. | |
| LogSink (LogMessage::Priority filter=LogMessage::NORMAL, Bool nullSink=True) | |
| Create a null local sink that throws all messages away or create a memory local sink that holds the messages in memory. | |
| LogSink (const LogFilterInterface &filter, Bool nullSink=True) | |
| LogSink (LogMessage::Priority filter, ostream *os) | |
| Log to an ostream. | |
| LogSink (const LogFilterInterface &filter, ostream *os) | |
| LogSink (const LogSink &other) | |
Make a referencing copy of other. | |
| LogSink & | operator= (const LogSink &other) |
| virtual Double | getTime (uInt i) const |
| Get given part of the i-th message from the local 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 |
| virtual const LogFilterInterface & | filter () const |
Get or set the filter of this particular LogSink. | |
| virtual LogSinkInterface & | filter (const LogFilterInterface &filter) |
| const LogSinkInterface & | localSink () const |
Change the sink that this LogSink actually uses. | |
| LogSinkInterface & | localSink () |
| LogSink & | localSink (LogSinkInterface *&fromNew) |
Static Public Member Functions | |
| static Bool | postGlobally (const LogMessage &message) |
Send message to the global sink only. | |
| static String | localId () |
| Returns the id for this class. | |
| static LogSinkInterface & | globalSink () |
| Get/set the global sink or check if the global sink is null. | |
| static void | globalSink (LogSinkInterface *&fromNew) |
| static Bool | nullGlobalSink () |
Private Attributes | |
| CountedPtr< LogSinkInterface > | local_sink_p |
| CountedPtr< LogSinkInterface > | local_ref_to_global_p |
| The following is a reference to the global sink. | |
Static Private Attributes | |
| static CountedPtr< LogSinkInterface > * | global_sink_p |
| casa::LogSink::LogSink | ( | LogMessage::Priority | filter = LogMessage::NORMAL, |
|
| Bool | nullSink = True | |||
| ) | [explicit] |
Create a null local sink that throws all messages away or create a memory local sink that holds the messages in memory.
If a filter isn't defined, default to NORMAL.
| casa::LogSink::LogSink | ( | const LogFilterInterface & | filter, | |
| Bool | nullSink = True | |||
| ) | [explicit] |
| casa::LogSink::LogSink | ( | LogMessage::Priority | filter, | |
| ostream * | os | |||
| ) |
Log to an ostream.
It is the responsiblity of the caller to ensure that os will last as long as the LogSinks that use it. Normally you would use &cerr as the argument.
| casa::LogSink::LogSink | ( | const LogFilterInterface & | filter, | |
| ostream * | os | |||
| ) |
| casa::LogSink::LogSink | ( | const LogFilterInterface & | filter, | |
| const CountedPtr< LogSinkInterface > & | ||||
| ) |
Log to the given sink.
It is primarily intended to log to a TableLogSink .
| casa::LogSink::LogSink | ( | const LogSink & | other | ) |
Make a referencing copy of other.
That is, if you post a message to the new object, it behaves as if you had posted it to the old one (so long as their filters are the same).
| casa::LogSink::LogSink | ( | const LogFilterInterface & | filter, | |
| const String & | fileName, | |||
| Int | n = 0 | |||
| ) |
Temporary to avoid problem that the bool constructor is taken if a char* is passed.
They are not implemented, so compiler should give warning. The 3rd argument is added to make it different from current version which is still in the system library.
| casa::LogSink::LogSink | ( | const LogFilterInterface & | filter, | |
| const Char * | fileName, | |||
| Int | n = 0 | |||
| ) |
| casa::LogSink::LogSink | ( | LogMessage::Priority | , | |
| const String & | fileName, | |||
| Int | n = 0 | |||
| ) |
| casa::LogSink::LogSink | ( | LogMessage::Priority | , | |
| const Char * | fileName, | |||
| Int | n = 0 | |||
| ) |
| casa::LogSink::~LogSink | ( | ) |
| Bool casa::LogSink::post | ( | const LogMessage & | message | ) |
Send message to both the local and global sink.
Return True if it passes either of them.
| static Bool casa::LogSink::postGlobally | ( | const LogMessage & | message | ) | [static] |
Send message to the global sink only.
Returns True if it passes the filter.
| virtual Bool casa::LogSink::postLocally | ( | const LogMessage & | message | ) | [virtual] |
Send message to the local sink only.
Returns True if it passes the filter.
Implements casa::LogSinkInterface.
| void casa::LogSink::postThenThrow | ( | const LogMessage & | message | ) |
Post message and then throw an AipsError exception containing message.toString().
It is always posted as a SEVERE priority message, no matter what message.priority() says.
| static void casa::LogSink::postGloballyThenThrow | ( | const LogMessage & | message | ) | [static] |
| virtual uInt casa::LogSink::nelements | ( | ) | const [virtual] |
Get given part of the i-th message from the local sink.
Reimplemented from casa::LogSinkInterface.
Referenced by casa::LogHolderIterEntry::time().
| virtual void casa::LogSink::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.
The default implementation does nothing.
Reimplemented from casa::LogSinkInterface.
| virtual void casa::LogSink::clearLocally | ( | ) | [virtual] |
| virtual const LogFilterInterface& casa::LogSink::filter | ( | ) | const [virtual] |
| virtual LogSinkInterface& casa::LogSink::filter | ( | const LogFilterInterface & | filter | ) | [virtual] |
Reimplemented from casa::LogSinkInterface.
| const LogSinkInterface& casa::LogSink::localSink | ( | ) | const |
| LogSinkInterface& casa::LogSink::localSink | ( | ) |
| LogSink& casa::LogSink::localSink | ( | LogSinkInterface *& | fromNew | ) |
| static LogSinkInterface& casa::LogSink::globalSink | ( | ) | [static] |
Get/set the global sink or check if the global sink is null.
The global sink defaults to using cerr. Generally applications code shouldn't change the global sink.
| static void casa::LogSink::globalSink | ( | LogSinkInterface *& | fromNew | ) | [static] |
| static Bool casa::LogSink::nullGlobalSink | ( | ) | [static] |
Write any pending output (by default also the global sink).
Reimplemented from casa::LogSinkInterface.
| static String casa::LogSink::localId | ( | ) | [static] |
| String casa::LogSink::id | ( | ) | const [virtual] |
CountedPtr<LogSinkInterface>* casa::LogSink::global_sink_p [static, private] |
1.5.1