contents up previous next

wxlogchain

this simple class allows to chain log sinks, that is to install a new sink but keep passing log messages to the old one instead of replacing it completely as setactivetarget does.

it is especially useful when you want to divert the logs somewhere (for example to a file or a log window) but also keep showing the error messages using the standard dialogs as wxloggui does by default.

example of usage:

wxlogchain *logchain = new wxlogchain(new wxlogstderr);

// all the log messages are sent to stderr and also processed as usually
...

// don't delete logchain directly as this would leave a dangling
// pointer as active log target, use setactivetarget() instead
delete wxlog::setactivetarget(...something else or null...);

derived from

wxlog

include files

<wx/log.h>

members

wxlogchain::wxlogchain
wxlogchain::~wxlogchain
wxlogchain::detacholdlog
wxlogchain::getoldlog
wxlogchain::ispassingmessages
wxlogchain::passmessages
wxlogchain::setlog


wxlogchain::wxlogchain

wxlogchain(wxlog *logger)

sets the specified logger (which may be null) as the default log target but the log messages are also passed to the previous log target if any.


wxlogchain::~wxlogchain

~wxlogchain()

destroys the previous log target.


wxlogchain::detacholdlog

void detacholdlog()

detaches the old log target so it won't be destroyed when the wxlogchain object is destroyed.


wxlogchain::getoldlog

wxlog * getoldlog() const

returns the pointer to the previously active log target (which may be null).


wxlogchain::ispassingmessages

bool ispassingmessages() const

returns true if the messages are passed to the previously active log target (default) or false if passmessages had been called.


wxlogchain::passmessages

void passmessages(bool passmessages)

by default, the log messages are passed to the previously active log target. calling this function with false parameter disables this behaviour (presumably temporarily, as you shouldn't use wxlogchain at all otherwise) and it can be reenabled by calling it again with passmessages set to true.


wxlogchain::setlog

void setlog(wxlog *logger)

sets another log target to use (may be null). the log target specified in the constructor or in a previous call to this function is deleted.

this doesn't change the old log target value (the one the messages are forwarded to) which still remains the same as was active when wxlogchain object was created.