| Version: 3.1.5

Classes | Macros | Typedefs | Enumerations | Functions
log.h File Reference

## Classes
class | wxLogRecordInfo
| Information about a log record (unit of the log output). More...
class | wxLogFormatter
| wxLogFormatter class is used to format the log messages. More...
class | wxLog
| wxLog class defines the interface for the log targets used by wxWidgets logging functions as explained in the Logging Overview. More...
class | wxLogChain
| This simple class allows you 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 wxLog::SetActiveTarget does. More...
class | wxLogInterposer
| A special version of wxLogChain which uses itself as the new log target. More...
class | wxLogInterposerTemp
| A special version of wxLogChain which uses itself as the new log target. More...
class | wxLogStream
| This class can be used to redirect the log messages to a C++ stream. More...
class | wxLogStderr
| This class can be used to redirect the log messages to a C file stream (not to be confused with C++ streams). More...
class | wxLogBuffer
| wxLogBuffer is a very simple implementation of log sink which simply collects all the logged messages in a string (except the debug messages which are output in the usual way immediately as we're presumably not interested in collecting them for later). More...
class | wxLogNull
| This class allows you to temporarily suspend logging. More...
class | wxLogWindow
| This class represents a background log window: to be precise, it collects all log messages in the log frame which it manages but also passes them on to the log target which was active at the moment of its creation. More...
class | wxLogGui
| This is the default log target for the GUI wxWidgets applications. More...
class | wxLogTextCtrl
| Using these target all the log messages can be redirected to a text control. More...

## Macros
#define | wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD()
| Use this macro to disable logging at debug and trace levels in release build when not using wxIMPLEMENT_APP(). More...

## Typedefs
typedef unsigned long | wxLogLevel
| The type used to specify a log level. More...

## Enumerations
enum | wxLogLevelValues { wxLOG_FatalError , wxLOG_Error , wxLOG_Warning , wxLOG_Message , wxLOG_Status , wxLOG_Info , wxLOG_Debug , wxLOG_Trace , wxLOG_Progress , wxLOG_User = 100 , wxLOG_Max = 10000 }
| Different standard log levels (you may also define your own) used with by standard wxLog functions wxLogGeneric(), wxLogError(), wxLogWarning(), etc... More...

## Functions
bool | wxSafeShowMessage (const wxString &title, const wxString &text)
| This function shows a message to the user in a safe way and should be safe to call even before the application has been initialized or if it is currently in some other strange state (for example, about to crash). More...
unsigned long | wxSysErrorCode ()
| Returns the error code from the last system call. More...
wxString | wxSysErrorMsgStr (unsigned long errCode=0)
| Returns the error message corresponding to the given system error code. More...
const wxChar * | wxSysErrorMsg (unsigned long errCode=0)
| Returns the error message corresponding to the given system error code. More...
void | wxLogGeneric (wxLogLevel level, const char *formatString,...)
| Logs a message with the given wxLogLevel. More...
void | wxVLogGeneric (wxLogLevel level, const char *formatString, va_list argPtr)
void | wxLogMessage (const char *formatString,...)
| For all normal, informational messages. More...
void | wxVLogMessage (const char *formatString, va_list argPtr)
void | wxLogInfo (const char *formatString,...)
| For low priority messages. More...
void | wxVLogInfo (const char *formatString, va_list argPtr)
void | wxLogVerbose (const char *formatString,...)
| For verbose output. More...
void | wxVLogVerbose (const char *formatString, va_list argPtr)
void | wxLogWarning (const char *formatString,...)
| For warnings - they are also normally shown to the user, but don't interrupt the program work. More...
void | wxVLogWarning (const char *formatString, va_list argPtr)
void | wxLogFatalError (const char *formatString,...)
| Like wxLogError(), but also terminates the program with the exit code 3. More...
void | wxVLogFatalError (const char *formatString, va_list argPtr)
void | wxLogError (const char *formatString,...)
| The functions to use for error messages, i.e. More...
void | wxVLogError (const char *formatString, va_list argPtr)
void | wxLogTrace (const char *mask, const char *formatString,...)
| Log a message at `wxLOG_Trace` log level (see wxLogLevelValues enum). More...
void | wxVLogTrace (const char *mask, const char *formatString, va_list argPtr)
void | wxLogTrace (wxTraceMask mask, const char *formatString,...)
| Like wxLogDebug(), trace functions only do something in debug builds and expand to nothing in the release one. More...
void | wxVLogTrace (wxTraceMask mask, const char *formatString, va_list argPtr)
void | wxLogDebug (const char *formatString,...)
| The right functions for debug output. More...
void | wxVLogDebug (const char *formatString, va_list argPtr)
void | wxLogStatus (wxFrame *frame, 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. More...
void | wxVLogStatus (wxFrame *frame, const char *formatString, va_list argPtr)
void | wxLogStatus (const char *formatString,...)
void | wxVLogStatus (const char *formatString, va_list argPtr)
void | wxLogSysError (const char *formatString,...)
| Mostly used by wxWidgets itself, but might be handy for logging errors after system call (API function) failure. More...
void | wxVLogSysError (const char *formatString, va_list argPtr)

## Macro Definition Documentation

## ◆ wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD

#define wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD | ( |  | ) |

Use this macro to disable logging at debug and trace levels in release build when not using wxIMPLEMENT_APP().

See also
  wxDISABLE_DEBUG_SUPPORT(), wxDISABLE_ASSERTS_IN_RELEASE_BUILD(), Debugging

Since
  2.9.1

Include file:

    #include <wx/log.h>

## Typedef Documentation

## ◆ wxLogLevel

typedef unsigned long wxLogLevel

The type used to specify a log level.

Default values of wxLogLevel used by wxWidgets are contained in the wxLogLevelValues enumeration.

## Enumeration Type Documentation

## ◆ wxLogLevelValues

enum wxLogLevelValues

Different standard log levels (you may also define your own) used with by standard wxLog functions wxLogGeneric(), wxLogError(), wxLogWarning(), etc...

Enumerator
wxLOG_FatalError | program can't continue, abort immediately
wxLOG_Error | a serious error, user must be informed about it
wxLOG_Warning | user is normally informed about it but may be ignored
wxLOG_Message | normal message (i.e. normal output of a non GUI app)
wxLOG_Status | informational: might go to the status line of GUI app
wxLOG_Info | informational message (a.k.a. 'Verbose')
wxLOG_Debug | never shown to the user, disabled in release mode
wxLOG_Trace | trace messages are also only enabled in debug mode
wxLOG_Progress | used for progress indicator (not yet)
wxLOG_User | user defined levels start here
wxLOG_Max |

## Function Documentation

## ◆ wxLogDebug()

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

The right functions for debug output.

They only do something in debug mode (when the preprocessor symbol `WXDEBUG` is defined) and expand to nothing in release mode (otherwise).

Include file:

    #include <wx/log.h>

## ◆ wxLogError()

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

The functions 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.

Include file:

    #include <wx/log.h>

## ◆ 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.

Include file:

    #include <wx/log.h>

## ◆ wxLogGeneric()

void wxLogGeneric | ( | wxLogLevel | level,
|  | const char * | formatString,
|  |  | ...
| ) |  |

Logs a message with the given wxLogLevel.

E.g. using `wxLOG_Message` as first argument, this function behaves like wxLogMessage().

Include file:

    #include <wx/log.h>

## ◆ wxLogInfo()

void wxLogInfo | ( | const char * | formatString,
|  |  | ...
| ) |  |

For low priority messages.

They are handled in the same way as messages logged by wxLogMessage() by the default logger but could be handled differently by the custom loggers.

Include file:

    #include <wx/log.h>

## ◆ 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).

Include file:

    #include <wx/log.h>

## ◆ wxLogStatus() [1/2]

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

## ◆ wxLogStatus() [2/2]

void wxLogStatus | ( | wxFrame * | frame,
|  | 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 functions).

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

Include file:

    #include <wx/log.h>

## ◆ wxLogSysError()

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

Mostly used by wxWidgets 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(), wxSysErrorMsgStr()

Include file:

    #include <wx/log.h>

## ◆ wxLogTrace() [1/2]

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

Log a message at `wxLOG_Trace` log level (see wxLogLevelValues enum).

Notice that the use of trace masks is not recommended any more as setting the log components (please see Log Messages Selection) provides a way to do the same thing for log messages of any level, and not just the tracing ones.

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

Trace messages can be separated into different categories; these functions in facts only log the message if the given mask is currently enabled in wxLog. This lets you selectively trace only some operations and not others by enabling the desired trace masks with wxLog::AddTraceMask() or by setting the `WXTRACE` environment variable.

The predefined string trace masks used by wxWidgets are:

wxTRACE_MemAlloc | Trace memory allocation (new/delete)
wxTRACE_Messages | Trace window messages/X callbacks
wxTRACE_ResAlloc | Trace GDI resource allocation
wxTRACE_RefCount | Trace various ref counting operations
wxTRACE_OleCalls | Trace OLE method calls (Win32 only)

Include file:

    #include <wx/log.h>

## ◆ wxLogTrace() [2/2]

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

Like wxLogDebug(), trace functions only do something in debug builds and expand to nothing in the release one.

The reason for making it a separate function is that usually there are a lot of trace messages, so it might make sense to separate them from other debug messages.

Deprecated:
  This version of wxLogTrace() only logs the message if all the bits corresponding to the mask are set in the wxLog trace mask which can be set by calling wxLog::SetTraceMask(). This version is less flexible than wxLogTrace(const char*,const char*,...) because it doesn't allow defining the user trace masks easily. This is why it is deprecated in favour of using string trace masks.

The following bitmasks are defined for wxTraceMask:

wxTraceMemAlloc | Trace memory allocation (new/delete)
wxTraceMessages | Trace window messages/X callbacks
wxTraceResAlloc | Trace GDI resource allocation
wxTraceRefCount | Trace various ref counting operations
wxTraceOleCalls | Trace OLE method calls (Win32 only)

Include file:

    #include <wx/log.h>

## ◆ wxLogVerbose()

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

For verbose output.

Messages generated by these functions are suppressed by default, even if the log level is higher than wxLOG_Info and need to be explicitly activated by calling wxLog::SetVerbose().

Notice that this is done automatically by wxWidgets, unless the standard command line handling is overridden, if `--verbose` option is specified on the program command line, so using these functions provides a simple way of having some diagnostic messages not shown by default but which can be easily shown by the user if needed.

Include file:

    #include <wx/log.h>

## ◆ wxLogWarning()

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

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

Include file:

    #include <wx/log.h>

## ◆ wxSafeShowMessage()

bool wxSafeShowMessage | ( | const wxString & | title,
|  | const wxString & | text
| ) |  |

This function shows a message to the user in a safe way and should be safe to call even before the application has been initialized or if it is currently in some other strange state (for example, about to crash).

Under Windows this function shows a message box using a native dialog instead of wxMessageBox() (which might be unsafe to call), elsewhere it simply prints the message to the standard output using the title as prefix.

Parameters

  title | The title of the message box shown to the user or the prefix of the message string.
  text | The text to show to the user.

Returns
  true If a message box was actually shown or false if the message was logged to the console because there is no safe to show it currently (the return value is only available since wxWidgets 3.1.5, the function doesn't return anything in the previous versions).

See also
  wxLogFatalError()

Include file:

    #include <wx/log.h>

## ◆ 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
  wxSysErrorMsgStr(), wxLogSysError()

Include file:

    #include <wx/log.h>

## ◆ 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.

Use wxSysErrorMsgStr() instead of this function especially in a multi-threaded application.

See also
  wxSysErrorCode(), wxLogSysError()

Include file:

    #include <wx/log.h>

## ◆ wxSysErrorMsgStr()

wxString wxSysErrorMsgStr | ( | 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.

Use this function instead of wxSysErrorMsg(), as the latter one is not thread-safe.

Since
  3.1.0

See also
  wxSysErrorCode(), wxLogSysError()

Include file:

    #include <wx/log.h>

## ◆ wxVLogDebug()

void wxVLogDebug | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogError()

void wxVLogError | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogFatalError()

void wxVLogFatalError | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogGeneric()

void wxVLogGeneric | ( | wxLogLevel | level,
|  | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogInfo()

void wxVLogInfo | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogMessage()

void wxVLogMessage | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogStatus() [1/2]

void wxVLogStatus | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogStatus() [2/2]

void wxVLogStatus | ( | wxFrame * | frame,
|  | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogSysError()

void wxVLogSysError | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogTrace() [1/2]

void wxVLogTrace | ( | const char * | mask,
|  | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogTrace() [2/2]

void wxVLogTrace | ( | wxTraceMask | mask,
|  | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogVerbose()

void wxVLogVerbose | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |

## ◆ wxVLogWarning()

void wxVLogWarning | ( | const char * | formatString,
|  | va_list | argPtr
| ) |  |