Version: 2.9.4
Public Member Functions | Protected Member Functions
wxLogFormatter Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/log.h>


Detailed Description

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

        class LogFormatterWithThread : public wxLogFormatter
        {
            virtual wxString Format(wxLogLevel level,
                                    const wxString& msg,
                                    const wxLogRecordInfo& info) const
            {
                return wxString::Format("[%d] %s(%d) : %s",
                    info.threadId, info.filename, info.line, msg);
            }
        };

And then associate it with wxLog instance using its SetFormatter(). Then, if you call:

        wxLogMessage(_("*** Application started ***"));

the log output could be something like:

        [7872] d:\testApp\src\testApp.cpp(85) : *** Application started ***
    

Library:  wxBase
Category:  Logging
参照:
wxLog クラスの概要
Since:
2.9.4

Public Member Functions

 wxLogFormatter ()
 The default ctor does nothing.
virtual wxString Format (wxLogLevel level, const wxString &msg, const wxLogRecordInfo &info) const
 This function creates the full log message string.

Protected Member Functions

virtual wxString FormatTime (time_t time) const
 This function formats the time stamp part of the log message.

List of all members.


Constructor & Destructor Documentation

wxLogFormatter::wxLogFormatter ( )

The default ctor does nothing.


Member Function Documentation

virtual wxString wxLogFormatter::Format ( wxLogLevel  level,
const wxString msg,
const wxLogRecordInfo info 
) const [virtual]

This function creates the full log message string.

Override it to customize the output string format.

Parameters:
levelThe level of this log record, e.g. wxLOG_Error.
msgThe log message itself.
infoAll the other information (such as time, component, location...) associated with this log record.
Returns:
The formated message.
注:
Time stamping is disabled for Visual C++ users in debug builds by default because otherwise it would be impossible to directly go to the line from which the log message was generated by simply clicking in the debugger window on the corresponding error message. If you wish to enable it, override FormatTime().
virtual wxString wxLogFormatter::FormatTime ( time_t  time) const [protected, virtual]

This function formats the time stamp part of the log message.

Override this function if you need to customize just the time stamp.

Parameters:
timeTime to format.
Returns:
The formated time string, may be empty.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines