#include <wx/log.h>
Allows to collect all log messages into a string instead of showing them.
This class is supposed to be used as a local variable and collects all the messages logged during its lifetime instead of showing them as usual, e.g.
Note that because this class uses wxLog::SetActiveTarget() to temporarily switch the active log target to wxLogBuffer, you need to ensure that the log target doesn't change while it is alive (in the simplest case by just avoiding to change it at all).
Public Member Functions | |
wxLogCollector () | |
Constructor overrides active log target to collect messages. More... | |
const wxString & | GetMessages () const |
Get all the collected messages. More... | |
~wxLogCollector () | |
Destructor restores the previously active log target. More... | |
wxLogCollector::wxLogCollector | ( | ) |
Constructor overrides active log target to collect messages.
wxLogCollector::~wxLogCollector | ( | ) |
Destructor restores the previously active log target.
const wxString& wxLogCollector::GetMessages | ( | ) | const |
Get all the collected messages.
The returned string may be empty but if it isn't, it contains the trailing new line (and may also contain more new lines inside it if multiple messages were logged).
Note that the messages here contain just the messages, without any time stamps or log level prefixes.