#include <wx/log.h>
wxLogFormatter class is used to format the log messages.
It implements the default formatting and can be derived from to create custom formatters.
The default implementation formats the message into a string containing the time stamp, level-dependent prefix and the message itself.
To change it, you can derive from it and override its Format() method. For example, to include the thread id in the log messages you can use
And then associate it with wxLog instance using its SetFormatter(). Then, if you call:
the log output could be something like:
[7872] d:\testApp\src\testApp.cpp(85) : *** Application started ***
See wxLogFormatterNone for a trivial version of this class not doing any formatting,
Public Member Functions | |
wxLogFormatter () | |
The default ctor does nothing. More... | |
virtual wxString | Format (wxLogLevel level, const wxString &msg, const wxLogRecordInfo &info) const |
This function creates the full log message string. More... | |
Protected Member Functions | |
virtual wxString | FormatTimeMS (wxLongLong_t msec) const |
This function formats the time stamp part of the log message including milliseconds. More... | |
virtual wxString | FormatTime (time_t time) const |
This function formats the time stamp part of the log message. More... | |
wxLogFormatter::wxLogFormatter | ( | ) |
The default ctor does nothing.
|
virtual |
This function creates the full log message string.
Override it to customize the output string format.
level | The level of this log record, e.g. wxLOG_Error. |
msg | The log message itself. |
info | All the other information (such as time, component, location...) associated with this log record. |
|
protectedvirtual |
This function formats the time stamp part of the log message.
Override this function if you need to customize just the time stamp.
time | Time to format. |
|
protectedvirtual |
This function formats the time stamp part of the log message including milliseconds.
Override this function if you need to customize just the time stamp formatting in the log messages.
msec | Time to format as the number of milliseconds since 1970-01-01T00:00:00. |