Contents Up Previous Next

Log functions

These functions provide a variety of logging functions: see Log classes overview for further information. The functions use (implicitly) the currently active log target, so their descriptions here may not apply if the log target is not the standard one (installed by wxWindows in the beginning of the program).

Include files

<wx/log.h>

::wxLogError
::wxLogFatalError
::wxLogWarning
::wxLogMessage
::wxLogVerbose
::wxLogStatus
::wxLogSysError
::wxLogDebug
::wxLogTrace
::wxSysErrorCode
::wxSysErrorMsg


::wxLogError

void wxLogError(const char* formatString, ...)

The function to use for error messages, i.e. the messages that must be shown to the user. The default processing is to pop up a message box to inform the user about it.


::wxLogFatalError

void wxLogFatalError(const char* formatString, ...)

Like wxLogError, but also terminates the program with the exit code 3. Using abort() standard function also terminates the program with this exit code.


::wxLogWarning

void wxLogWarning(const char* formatString, ...)

For warnings - they are also normally shown to the user, but don't interrupt the program work.


::wxLogMessage

void wxLogMessage(const char* formatString, ...)

for all normal, informational messages. They also appear in a message box by default (but it can be changed). Notice that the standard behaviour is to not show informational messages if there are any errors later - the logic being that the later error messages make the informational messages preceding them meaningless.


::wxLogVerbose

void wxLogVerbose(const char* formatString, ...)

For verbose output. Normally, it is suppressed, but might be activated if the user wishes to know more details about the program progress (another, but possibly confusing name for the same function is wxLogInfo).


::wxLogStatus

void wxLogStatus(wxFrame *frame, const char* formatString, ...)

void wxLogStatus(const char* formatString, ...)

Messages logged by this function will appear in the statusbar of the frame or of the top level application window by default (i.e. when using the second version of the function).

If the target frame doesn't have a statusbar, the message will be lost.


::wxLogSysError

void wxLogSysError(const char* formatString, ...)

Mostly used by wxWindows itself, but might be handy for logging errors after system call (API function) failure. It logs the specified message text as well as the last system error code (errno or ::GetLastError() depending on the platform) and the corresponding error message. The second form of this function takes the error code explicitly as the first argument.

See also

wxSysErrorCode, wxSysErrorMsg


::wxLogDebug

void wxLogDebug(const char* formatString, ...)

The right function for debug output. It only does anything at all in the debug mode (when the preprocessor symbol __WXDEBUG__ is defined) and expands to nothing in release mode (otherwise).


::wxLogTrace

void wxLogTrace(const char* formatString, ...)

void wxLogTrace(const char *mask, const char *formatString, ...)

void wxLogTrace(wxTraceMask mask, const char *formatString, ...)

As wxLogDebug, trace functions only do something in debug build and expand to nothing in the release one. The reason for making it a separate function from it is that usually there are a lot of trace messages, so it might make sense to separate them from other debug messages.

The trace messages also usually can be separated into different categories and the second and third versions of this function only log the message if the mask which it has is currently enabled in wxLog. This allows to selectively trace only some operations and not others by changing the value of the trace mask (possible during the run-time).

For the second function (taking a string mask), the message is logged only if the mask has been previously enabled by the call to AddTraceMask. The predefined string trace masks used by wxWindows are:

The third version of the function only logs the message if all the bit corresponding to the mask are set in the wxLog trace mask which can be set by SetTraceMask. This version is less flexible than the previous one because it doesn't allow defining the user trace masks easily - this is why it is deprecated in favour of using string trace masks.


::wxSysErrorCode

unsigned long wxSysErrorCode()

Returns the error code from the last system call. This function uses errno on Unix platforms and GetLastError under Win32.

See also

wxSysErrorMsg, wxLogSysError


::wxSysErrorMsg

const wxChar * wxSysErrorMsg(unsigned long errCode = 0)

Returns the error message corresponding to the given system error code. If errCode is 0 (default), the last error code (as returned by wxSysErrorCode) is used.

See also

wxSysErrorCode, wxLogSysError