The sink of a LoggerHolder can be different depending on the type of image.
E.g. for a transient image it can be a
MemoryLogSink, while for a persistent
image it will be a TableLogSink.
An important feature is that an LoggerHolder can have zero or more
parent LoggerHolder objects. In that way the log of the parent object
of an image object can be made part of the log of the image object itself,
without having to copy the log.
To iterate through all messages in a LoggerHolder (including all parents), the LoggerHolderIterator can be used. This is an STL-style const_iterator object.
LoggerHolder uses reference counting (of class LoggerHolderRep) to be able to retain the object after the (ImageInterface) object containing it is gone. Otherwise classes like SubImage would lose their log info.
LoggerHolder logger ("tLoggerHolder_tmp.log", True);
logger.logio() << "test1" << LogIO::POST;
logger.logio() << "test2" << LogIO::POST;
for (LoggerHolder::const_iterator iter = logger.begin();
iter != logger.end();
iter++) {
cout << iter->time() << ' ' << iter->message() << endl;
}
This example shows the construction of an LoggerHolder with a
TableLogSink sink. Thereafter some messages are written.
The latter part shows how to iterate through all messages.
LoggerHolder logger (False); logger.addParent (parent.logger()); logger.logio() << "test1" << LogIO::POST; logger.logio() << "test2" << LogIO::POST;This example shows the construction of an LoggerHolder with a MemoryLogSink sink (e.g. for a SubImage). Thereafter the logger of the parent image is added to it. Finally some messages are written.
Create with a TableLogSink.
Copy constructor (reference sematics).
Assignment (reference semantics).
Add a logger from a parent.
Append the entries of the other logger to this one.
Reopen a readonly logtable for read/write (if needed).
Reopen the log table if needed (after a tempClose).
Temporarily close all log tables. By default the possible parent log tables are also closed.
Unlock the log table.
Flush the log table.
Resync the log table (if needed).
Is the log table temporarily closed?
Get access to the logger. It assumes that it will be used to post a message, so it reopens the log table for read/write if needed).
Get access to the log sink (reopen the log table if needed). It is not assumed you want to write. If you want to do that, you should first call reopenRW() to ensure you can write.
Clear the log. It removes the parents and removes all messages from the sink.
Remove all parents.
Return the block of parents.
Define the STL-style iterators.
Only a const forward iterator is available.
It makes it possible to iterate through all messages in the logger.
Get the begin and end iterator object.
Define the STL-style iterators.
Only a const forward iterator is available.
It makes it possible to iterate through all messages in the logger.
const_iterator begin() const
LoggerHolder logger("log.name", False)
for (LoggerHolder::const_iterator iter=arr.begin();
iter!=arr.end(); iter++) {
cout << iter.message() << endl;
}
const_iterator end() const
LoggerHolder logger("log.name", False)
for (LoggerHolder::const_iterator iter=arr.begin();
iter!=arr.end(); iter++) {
cout << iter.message() << endl;
}
Create with a TableLogSink.
Copy constructor.
Assignment. It removes the current parents.
Add a logger from a parent.
Append the entries of the other logger to this one.
Reopen a readonly logtable for read/write (if needed).
Reopen the log table if needed (after a tempClose).
Temporarily close all log tables. By default the possible parent log tables are also closed.
Unlock the log table.
Flush the log table.
Resync the log table (if needed).
Is the log table temporarily closed?
Get access to the logger. It assumes that it will be used to post a message, so it reopens the log table for read/write if needed).
Get access to the log sink (reopen the log table if needed). It is not assumed you want to write. If you want to do that, you should first call reopenRW() to ensure you can write.
Clear the log. It removes the parents and removes all messages from the sink.
Remove all parents.
Return the block of parents.
Define the STL-style iterators.
Only a const forward iterator is available.
It makes it possible to iterate through all messages in the logger.
Get the begin and end iterator object.
Define the STL-style iterators.
Only a const forward iterator is available.
It makes it possible to iterate through all messages in the logger.
const_iterator begin() const
LoggerHolder logger("log.name", False)
for (LoggerHolder::const_iterator iter=arr.begin();
iter!=arr.end(); iter++) {
cout << iter.message() << endl;
}
const_iterator end() const
LoggerHolder logger("log.name", False)
for (LoggerHolder::const_iterator iter=arr.begin();
iter!=arr.end(); iter++) {
cout << iter.message() << endl;
}
Get the message parts.
Increment to next message. Returns False if at the end.
Get the entry.
Assignment is not needed, thus forbidden.
LoggerHolder logger ("tLoggerHolder_tmp.log", True);
logger.logio() << "test1" << LogIO::POST;
logger.logio() << "test2" << LogIO::POST;
for (LoggerHolder::const_iterator iter = logger.begin();
iter != logger.end();
iter++) {
cout << iter->time() << ' ' << iter->message() << endl;
}
Increment to next message.
Is the iterator not at the end yet?
Get the entry.