1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxLogWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 Different standard log levels (you may also define your own) used with
12 wxLog::OnLog() by standard wxLog functions wxLogError(), wxLogWarning(),
17 wxLOG_FatalError
, //!< program can't continue, abort immediately
18 wxLOG_Error
, //!< a serious error, user must be informed about it
19 wxLOG_Warning
, //!< user is normally informed about it but may be ignored
20 wxLOG_Message
, //!< normal message (i.e. normal output of a non GUI app)
21 wxLOG_Status
, //!< informational: might go to the status line of GUI app
22 wxLOG_Info
, //!< informational message (a.k.a. 'Verbose')
23 wxLOG_Debug
, //!< never shown to the user, disabled in release mode
24 wxLOG_Trace
, //!< trace messages are also only enabled in debug mode
25 wxLOG_Progress
, //!< used for progress indicator (not yet)
26 wxLOG_User
= 100, //!< user defined levels start here
31 The type used for trace masks.
33 typedef unsigned long wxTraceMask
;
36 The type used to specify a log level.
38 Default values of ::wxLogLevel used by wxWidgets are contained in the
39 ::wxLogLevelValues enumeration.
41 typedef unsigned long wxLogLevel
;
47 This class represents a background log window: to be precise, it collects all
48 log messages in the log frame which it manages but also passes them on to the
49 log target which was active at the moment of its creation. This allows you, for
50 example, to show all the log messages in a frame but still continue to process
51 them normally by showing the standard log dialog.
58 class wxLogWindow
: public wxLogInterposer
62 Creates the log frame window and starts collecting the messages in it.
65 The parent window for the log frame, may be @NULL
67 The title for the log frame
69 @true to show the frame initially (default), otherwise
70 Show() must be called later.
72 @true to process the log messages normally in addition to
73 logging them in the log frame (default), @false to only log them in the
76 wxLogWindow(wxWindow
* pParent
, const wxString
& szTitle
, bool show
= true,
77 bool passToOld
= true);
80 Returns the associated log frame window. This may be used to position or resize
81 it but use Show() to show or hide it.
83 wxFrame
* GetFrame() const;
86 Called if the user closes the window interactively, will not be
87 called if it is destroyed for another reason (such as when program
90 Return @true from here to allow the frame to close, @false to
91 prevent this from happening.
95 virtual bool OnFrameClose(wxFrame
* frame
);
98 Called immediately after the log frame creation allowing for
99 any extra initializations.
101 virtual void OnFrameCreate(wxFrame
* frame
);
104 Called right before the log frame is going to be deleted: will
105 always be called unlike OnFrameClose().
107 virtual void OnFrameDelete(wxFrame
* frame
);
110 Shows or hides the frame.
112 void Show(bool show
= true);
118 @class wxLogInterposerTemp
120 A special version of wxLogChain which uses itself as the new log target.
121 It forwards log messages to the previously installed one in addition to
122 processing them itself. Unlike wxLogInterposer, it doesn't delete the old
123 target which means it can be used to temporarily redirect log output.
125 As per wxLogInterposer, this class must be derived from to implement
126 wxLog::DoLog and/or wxLog::DoLogString methods.
131 class wxLogInterposerTemp
: public wxLogChain
135 The default constructor installs this object as the current active log target.
137 wxLogInterposerTemp();
145 This simple class allows you to chain log sinks, that is to install a new sink but
146 keep passing log messages to the old one instead of replacing it completely as
147 wxLog::SetActiveTarget does.
149 It is especially useful when you want to divert the logs somewhere (for
150 example to a file or a log window) but also keep showing the error messages
151 using the standard dialogs as wxLogGui does by default.
156 wxLogChain *logChain = new wxLogChain(new wxLogStderr);
158 // all the log messages are sent to stderr and also processed as usually
161 // don't delete logChain directly as this would leave a dangling
162 // pointer as active log target, use SetActiveTarget() instead
163 delete wxLog::SetActiveTarget(...something else or NULL...);
169 class wxLogChain
: public wxLog
173 Sets the specified @c logger (which may be @NULL) as the default log
174 target but the log messages are also passed to the previous log target if any.
176 wxLogChain(wxLog
* logger
);
179 Destroys the previous log target.
181 virtual ~wxLogChain();
184 Detaches the old log target so it won't be destroyed when the wxLogChain object
190 Returns the pointer to the previously active log target (which may be @NULL).
192 wxLog
* GetOldLog() const;
195 Returns @true if the messages are passed to the previously active log
196 target (default) or @false if PassMessages() had been called.
198 bool IsPassingMessages() const;
201 By default, the log messages are passed to the previously active log target.
202 Calling this function with @false parameter disables this behaviour
203 (presumably temporarily, as you shouldn't use wxLogChain at all otherwise) and
204 it can be reenabled by calling it again with @a passMessages set to @true.
206 void PassMessages(bool passMessages
);
209 Sets another log target to use (may be @NULL).
211 The log target specified in the wxLogChain(wxLog*) constructor or in a
212 previous call to this function is deleted.
213 This doesn't change the old log target value (the one the messages are
214 forwarded to) which still remains the same as was active when wxLogChain
217 void SetLog(wxLog
* logger
);
225 This is the default log target for the GUI wxWidgets applications.
227 Please see @ref overview_log_customize for explanation of how to change the
230 An object of this class is used by default to show the log messages created
231 by using wxLogMessage(), wxLogError() and other logging functions. It
232 doesn't display the messages logged by them immediately however but
233 accumulates all messages logged during an event handler execution and then
234 shows them all at once when its Flush() method is called during the idle
235 time processing. This has the important advantage of showing only a single
236 dialog to the user even if several messages were logged because of a single
237 error as it often happens (e.g. a low level function could log a message
238 because it failed to open a file resulting in its caller logging another
239 message due to the failure of higher level operation requiring the use of
240 this file). If you need to force the display of all previously logged
241 messages immediately you can use wxLog::FlushActive() to force the dialog
244 Also notice that if an error message is logged when several informative
245 messages had been already logged before, the informative messages are
246 discarded on the assumption that they are not useful -- and may be
247 confusing and hence harmful -- any more after the error. The warning
248 and error messages are never discarded however and any informational
249 messages logged after the first error one are also kept (as they may
250 contain information about the error recovery). You may override DoLog()
251 method to change this behaviour.
253 At any rate, it is possible that that several messages were accumulated
254 before this class Flush() method is called. If this is the case, Flush()
255 uses a custom dialog which shows the last message directly and allows the
256 user to view the previously logged ones by expanding the "Details"
257 wxCollapsiblePane inside it. This custom dialog also provides the buttons
258 for copying the log messages to the clipboard and saving them to a file.
260 However if only a single message is present when Flush() is called, just a
261 wxMessageBox() is used to show it. This has the advantage of being closer
262 to the native behaviour but it doesn't give the user any possibility to
263 copy or save the message (except for the recent Windows versions where @c
264 Ctrl-C may be pressed in the message box to copy its contents to the
265 clipboard) so you may want to override DoShowSingleMessage() to customize
266 wxLogGui -- the dialogs sample shows how to do this.
271 class wxLogGui
: public wxLog
280 Presents the accumulated log messages, if any, to the user.
282 This method is called during the idle time and should show any messages
283 accumulated in wxLogGui#m_aMessages field to the user.
285 virtual void Flush();
289 Returns the appropriate title for the dialog.
291 The title is constructed from wxApp::GetAppDisplayName() and the
292 severity string (e.g. "error" or "warning") appropriate for the current
293 wxLogGui#m_bErrors and wxLogGui#m_bWarnings values.
295 wxString
GetTitle() const;
298 Returns wxICON_ERROR, wxICON_WARNING or wxICON_INFORMATION depending on
299 the current maximal severity.
301 This value is suitable to be used in the style parameter of
302 wxMessageBox() function.
304 int GetSeverityIcon() const;
307 Forgets all the currently stored messages.
309 If you override Flush() (and don't call the base class version), you
310 must call this method to avoid messages being logged over and over
317 Method called by Flush() to show a single log message.
319 This function can be overridden to show the message in a different way.
320 By default a simple wxMessageBox() call is used.
323 The message to show (it can contain multiple lines).
325 The suggested title for the dialog showing the message, see
328 One of @c wxICON_XXX constants, see GetSeverityIcon().
330 virtual void DoShowSingleLogMessage(const wxString
& message
,
331 const wxString
& title
,
335 Method called by Flush() to show multiple log messages.
337 This function can be overridden to show the messages in a different way.
338 By default a special log dialog showing the most recent message and
339 allowing the user to expand it to view the previously logged ones is
343 Array of messages to show; it contains more than one element.
345 Array of message severities containing @c wxLOG_XXX values.
347 Array of time_t values indicating when each message was logged.
349 The suggested title for the dialog showing the message, see
352 One of @c wxICON_XXX constants, see GetSeverityIcon().
354 virtual void DoShowMultipleLogMessages(const wxArrayString
& messages
,
355 const wxArrayInt
& severities
,
356 const wxArrayLong
& times
,
357 const wxString
& title
,
362 All currently accumulated messages.
364 This array may be empty if no messages were logged.
366 @see m_aSeverity, m_aTimes
368 wxArrayString m_aMessages
;
371 The severities of each logged message.
373 This array is synchronized with wxLogGui#m_aMessages, i.e. the n-th
374 element of this array corresponds to the severity of the n-th message.
375 The possible severity values are @c wxLOG_XXX constants, e.g.
376 wxLOG_Error, wxLOG_Warning, wxLOG_Message etc.
378 wxArrayInt m_aSeverity
;
381 The time stamps of each logged message.
383 The elements of this array are time_t values corresponding to the time
384 when the message was logged.
386 wxArrayLong m_aTimes
;
389 True if there any error messages.
394 True if there any warning messages.
396 If both wxLogGui#m_bErrors and this member are false, there are only
397 informational messages to be shown.
402 True if there any messages to be shown to the user.
404 This variable is used instead of simply checking whether
405 wxLogGui#m_aMessages array is empty to allow blocking further calls to
406 Flush() while a log dialog is already being shown, even if the messages
407 array hasn't been emptied yet.
417 This class can be used to redirect the log messages to a C++ stream.
419 Please note that this class is only available if wxWidgets was compiled with
420 the standard iostream library support (@c wxUSE_STD_IOSTREAM must be on).
425 @see wxLogStderr, wxStreamToTextRedirector
427 class wxLogStream
: public wxLog
431 Constructs a log target which sends all the log messages to the given
432 output stream. If it is @NULL, the messages are sent to @c cerr.
434 wxLogStream(std::ostream
*ostr
= NULL
);
442 This class can be used to redirect the log messages to a C file stream (not to
443 be confused with C++ streams).
445 It is the default log target for the non-GUI wxWidgets applications which
446 send all the output to @c stderr.
453 class wxLogStderr
: public wxLog
457 Constructs a log target which sends all the log messages to the given
458 @c FILE. If it is @NULL, the messages are sent to @c stderr.
460 wxLogStderr(FILE* fp
= NULL
);
468 wxLogBuffer is a very simple implementation of log sink which simply collects
469 all the logged messages in a string (except the debug messages which are output
470 in the usual way immediately as we're presumably not interested in collecting
471 them for later). The messages from different log function calls are separated
474 All the messages collected so far can be shown to the user (and the current
475 buffer cleared) by calling the overloaded wxLogBuffer::Flush method.
480 class wxLogBuffer
: public wxLog
484 The default ctor does nothing.
489 Shows all the messages collected so far to the user (using a message box in the
490 GUI applications or by printing them out to the console in text mode) and
491 clears the internal buffer.
493 virtual void Flush();
496 Returns the current buffer contains. Messages from different log function calls
497 are separated with the new lines in the buffer.
498 The buffer can be cleared by Flush() which will also show the current
499 contents to the user.
501 const wxString
& GetBuffer() const;
507 @class wxLogInterposer
509 A special version of wxLogChain which uses itself as the new log target.
510 It forwards log messages to the previously installed one in addition to
511 processing them itself.
513 Unlike wxLogChain which is usually used directly as is, this class must be
514 derived from to implement wxLog::DoLog and/or wxLog::DoLogString methods.
516 wxLogInterposer destroys the previous log target in its destructor.
517 If you don't want this to happen, use wxLogInterposerTemp instead.
522 class wxLogInterposer
: public wxLogChain
526 The default constructor installs this object as the current active log target.
536 Using these target all the log messages can be redirected to a text control.
537 The text control must have been created with @c wxTE_MULTILINE style by the
543 @see wxTextCtrl, wxStreamToTextRedirector
545 class wxLogTextCtrl
: public wxLog
549 Constructs a log target which sends all the log messages to the given text
550 control. The @a textctrl parameter cannot be @NULL.
552 wxLogTextCtrl(wxTextCtrl
* pTextCtrl
);
560 wxLog class defines the interface for the @e log targets used by wxWidgets
561 logging functions as explained in the @ref overview_log.
562 The only situations when you need to directly use this class is when you want
563 to derive your own log target because the existing ones don't satisfy your
564 needs. Another case is if you wish to customize the behaviour of the standard
565 logging classes (all of which respect the wxLog settings): for example, set
566 which trace messages are logged and which are not or change (or even remove
567 completely) the timestamp on the messages.
569 Otherwise, it is completely hidden behind the @e wxLogXXX() functions and
570 you may not even know about its existence.
572 @note For console-mode applications, the default target is wxLogStderr, so
573 that all @e wxLogXXX() functions print on @c stderr when @c wxUSE_GUI = 0.
576 @section log_derivingyours Deriving your own log target
578 There are two functions which must be implemented by any derived class to
579 actually process the log messages: DoLog() and DoLogString().
580 The second function receives a string which just has to be output in some way
581 and the easiest way to write a new log target is to override just this function
582 in the derived class.
584 If more control over the output format is needed, then the first function must
585 be overridden which allows to construct custom messages depending on the log level
586 or even do completely different things depending on the message severity
587 (for example, throw away all messages except warnings and errors, show warnings
588 on the screen and forward the error messages to the user's (or programmer's) cell
589 phone - maybe depending on whether the timestamp tells us if it is day or
590 night in the current time zone).
592 There also functions to support message buffering. Why are they needed?
593 Some of wxLog implementations, most notably the standard wxLogGui class,
594 buffer the messages (for example, to avoid showing the user a zillion of modal
595 message boxes one after another -- which would be really annoying).
597 Flush() shows them all and clears the buffer contents.
598 This function doesn't do anything if the buffer is already empty.
605 @section log_tracemasks Using trace masks
607 The functions below allow some limited customization of wxLog behaviour
608 without writing a new log target class (which, aside from being a matter of
609 several minutes, allows you to do anything you want).
610 The verbose messages are the trace messages which are not disabled in the
611 release mode and are generated by wxLogVerbose().
612 They are not normally shown to the user because they present little interest,
613 but may be activated, for example, in order to help the user find some program
616 As for the (real) trace messages, their handling depends on the settings of
617 the (application global) @e trace mask which can either be specified using
618 SetTraceMask(), GetTraceMask() and wxLogTrace() which takes an integer mask
619 or using AddTraceMask() for string trace masks.
621 The difference between bit-wise and string trace masks is that a message using
622 integer trace mask will only be logged if all bits of the mask are set in the
623 current mask while a message using string mask will be logged simply if the
624 mask had been added before to the list of allowed ones.
628 wxLogTrace( wxTraceRefCount|wxTraceOleCalls, "Active object ref count: %d", nRef );
631 will do something only if the current trace mask contains both @c wxTraceRefCount
632 and @c wxTraceOle, but:
635 wxLogTrace( wxTRACE_OleCalls, "IFoo::Bar() called" );
638 will log the message if it was preceded by:
641 wxLog::AddTraceMask( wxTRACE_OleCalls);
644 Using string masks is simpler and allows you to easily add custom ones, so this
645 is the preferred way of working with trace messages. The integer trace mask is
646 kept for compatibility and for additional (but very rarely needed) flexibility
649 The standard trace masks are given in wxLogTrace() documentation.
651 Finally, the @e wxLog::DoLog() function automatically prepends a time stamp
652 to all the messages. The format of the time stamp may be changed: it can be
653 any string with % specifications fully described in the documentation of the
654 standard @e strftime() function. For example, the default format is
655 "[%d/%b/%y %H:%M:%S] " which gives something like "[17/Sep/98 22:10:16] "
656 (without quotes) for the current date. Setting an empty string as the time
657 format or calling the shortcut wxLog::DisableTimestamp(), disables timestamping
658 of the messages completely.
662 @li RemoveTraceMask()
663 @li ClearTraceMasks()
665 @li IsAllowedTraceMask()
672 @li SetRepetitionCounting()
673 @li GetRepetitionCounting()
676 Timestamping is disabled for Visual C++ users in debug builds by
677 default because otherwise it would be impossible to directly go to the line
678 from which the log message was generated by simply clicking in the debugger
679 window on the corresponding error message. If you wish to enable it, please
680 use SetTimestamp() explicitly.
683 @section log_target Manipulating the log target
685 The functions in this section work with and manipulate the active log
686 target. The OnLog() is called by the @e wxLogXXX() functions
687 and invokes the DoLog() of the active log target if any.
689 Get/Set methods are used to install/query the current active target and,
690 finally, DontCreateOnDemand() disables the automatic creation of a standard
691 log target if none actually exists. It is only useful when the application
692 is terminating and shouldn't be used in other situations because it may
693 easily lead to a loss of messages.
697 @li GetActiveTarget()
698 @li SetActiveTarget()
699 @li DontCreateOnDemand()
707 @see @ref overview_log
713 Add the @a mask to the list of allowed masks for wxLogTrace().
715 @see RemoveTraceMask(), GetTraceMasks()
717 static void AddTraceMask(const wxString
& mask
);
720 Removes all trace masks previously set with AddTraceMask().
722 @see RemoveTraceMask()
724 static void ClearTraceMasks();
727 Instructs wxLog to not create new log targets on the fly if there is none
728 currently. (Almost) for internal use only: it is supposed to be called by the
729 application shutdown code.
731 Note that this function also calls ClearTraceMasks().
733 static void DontCreateOnDemand();
736 Shows all the messages currently in buffer and clears it.
737 If the buffer is already empty, nothing happens.
739 virtual void Flush();
742 Flushes the current log target if any, does nothing if there is none.
746 static void FlushActive();
749 Returns the pointer to the active log target (may be @NULL).
751 static wxLog
* GetActiveTarget();
754 Returns the current log level limit.
756 static wxLogLevel
GetLogLevel();
759 Returns whether the repetition counting mode is enabled.
761 static bool GetRepetitionCounting();
764 Returns the current timestamp format string.
766 static const wxString
& GetTimestamp();
769 Returns the current trace mask, see Customization() section for details.
771 static wxTraceMask
GetTraceMask();
774 Returns the currently allowed list of string trace masks.
778 static const wxArrayString
& GetTraceMasks();
781 Returns whether the verbose mode is currently active.
783 static bool GetVerbose();
786 Returns @true if the @a mask is one of allowed masks for wxLogTrace().
788 See also: AddTraceMask(), RemoveTraceMask()
790 static bool IsAllowedTraceMask(const wxString
& mask
);
793 Forwards the message at specified level to the @e DoLog() function of the
794 active log target if there is any, does nothing otherwise.
796 static void OnLog(wxLogLevel level
, const wxString
& msg
, time_t t
);
799 Remove the @a mask from the list of allowed masks for
804 static void RemoveTraceMask(const wxString
& mask
);
807 Resumes logging previously suspended by a call to Suspend().
808 All messages logged in the meanwhile will be flushed soon.
810 static void Resume();
813 Sets the specified log target as the active one.
815 Returns the pointer to the previous active log target (may be @NULL).
816 To suppress logging use a new instance of wxLogNull not @NULL. If the
817 active log target is set to @NULL a new default log target will be
818 created when logging occurs.
820 static wxLog
* SetActiveTarget(wxLog
* logtarget
);
823 Specifies that log messages with level greater (numerically) than
824 @a logLevel should be ignored and not sent to the active log target.
826 static void SetLogLevel(wxLogLevel logLevel
);
829 Enables logging mode in which a log message is logged once, and in case exactly
830 the same message successively repeats one or more times, only the number of
831 repetitions is logged.
833 static void SetRepetitionCounting(bool repetCounting
= true);
836 Sets the timestamp format prepended by the default log targets to all
837 messages. The string may contain any normal characters as well as %
838 prefixed format specificators, see @e strftime() manual for details.
839 Passing an empty string to this function disables message time stamping.
841 static void SetTimestamp(const wxString
& format
);
844 Disables time stamping of the log messages.
848 static void DisableTimestamp();
851 Sets the trace mask, see @ref log_derivingyours section for details.
853 static void SetTraceMask(wxTraceMask mask
);
856 Activates or deactivates verbose mode in which the verbose messages are
857 logged as the normal ones instead of being silently dropped.
859 static void SetVerbose(bool verbose
= true);
862 Suspends the logging until Resume() is called.
864 Note that the latter must be called the same number of times as the former
865 to undo it, i.e. if you call Suspend() twice you must call Resume() twice as well.
867 Note that suspending the logging means that the log sink won't be be flushed
868 periodically, it doesn't have any effect if the current log target does the
869 logging immediately without waiting for Flush() to be called (the standard
870 GUI log target only shows the log dialog when it is flushed, so Suspend()
871 works as expected with it).
873 @see Resume(), wxLogNull
875 static void Suspend();
878 Log the given message.
880 This function should only be called from the DoLog() implementations in
881 the derived classes (which can't call wxLog::DoLog() directly as it is
882 protected), it should not be used for logging new messages which can be
883 only sent to the currently active logger using OnLog() which also
884 checks if the logging (for this level) is enabled while this method
885 just directly calls DoLog().
887 Example of use of this class from wxLogChain:
889 void wxLogChain::DoLog(wxLogLevel level, const wxString& msg, time_t t)
891 // let the previous logger show it
892 if ( m_logOld && IsPassingMessages() )
893 m_logOld->Log(level, msg, t);
895 // and also send it to the new one
896 if ( m_logNew && m_logNew != this )
897 m_logNew->Log(level, msg, t);
903 void Log(wxLogLevel level
, const wxString
& msg
, time_t timestamp
);
908 Called to process the message of the specified severity. @a msg is the text
909 of the message as specified in the call of @e wxLogXXX() function which
910 generated it and @a timestamp is the moment when the message was generated.
912 The base class version prepends the timestamp to the message, adds a prefix
913 corresponding to the log level and then calls
914 DoLogString() with the resulting string.
916 virtual void DoLog(wxLogLevel level
, const wxString
& msg
, time_t timestamp
);
919 Called to log the specified string. The timestamp is already included in the
920 string but still passed to this function.
922 A simple implementation may just send the string to @c stdout or, better,
925 virtual void DoLogString(const wxString
& msg
, time_t timestamp
);
933 This class allows you to temporarily suspend logging. All calls to the log
934 functions during the life time of an object of this class are just ignored.
936 In particular, it can be used to suppress the log messages given by wxWidgets
937 itself but it should be noted that it is rarely the best way to cope with this
938 problem as @b all log messages are suppressed, even if they indicate a
939 completely different error than the one the programmer wanted to suppress.
941 For instance, the example of the overview:
946 // wxFile.Open() normally complains if file can't be opened, we don't want it
949 if ( !file.Open("bar") )
950 ... process error ourselves ...
951 } // ~wxLogNull called, old log sink restored
953 wxLogMessage("..."); // ok
956 would be better written as:
961 // don't try to open file if it doesn't exist, we are prepared to deal with
962 // this ourselves - but all other errors are not expected
963 if ( wxFile::Exists("bar") )
965 // gives an error message if the file couldn't be opened
978 class wxLogNull
: public wxLog
994 // ============================================================================
995 // Global functions/macros
996 // ============================================================================
998 /** @addtogroup group_funcmacro_log */
1002 This function shows a message to the user in a safe way and should be safe
1003 to call even before the application has been initialized or if it is
1004 currently in some other strange state (for example, about to crash). Under
1005 Windows this function shows a message box using a native dialog instead of
1006 wxMessageBox() (which might be unsafe to call), elsewhere it simply prints
1007 the message to the standard output using the title as prefix.
1010 The title of the message box shown to the user or the prefix of the
1013 The text to show to the user.
1015 @see wxLogFatalError()
1019 void wxSafeShowMessage(const wxString
& title
, const wxString
& text
);
1022 Returns the error code from the last system call. This function uses
1023 @c errno on Unix platforms and @c GetLastError under Win32.
1025 @see wxSysErrorMsg(), wxLogSysError()
1029 unsigned long wxSysErrorCode();
1032 Returns the error message corresponding to the given system error code. If
1033 @a errCode is 0 (default), the last error code (as returned by
1034 wxSysErrorCode()) is used.
1036 @see wxSysErrorCode(), wxLogSysError()
1040 const wxChar
* wxSysErrorMsg(unsigned long errCode
= 0);
1044 /** @addtogroup group_funcmacro_log */
1047 For all normal, informational messages. They also appear in a message box
1048 by default (but it can be changed).
1052 void wxLogMessage(const char* formatString
, ... );
1053 void wxVLogMessage(const char* formatString
, va_list argPtr
);
1056 /** @addtogroup group_funcmacro_log */
1059 For verbose output. Normally, it is suppressed, but might be activated if
1060 the user wishes to know more details about the program progress (another,
1061 but possibly confusing name for the same function could be @c wxLogInfo).
1065 void wxLogVerbose(const char* formatString
, ... );
1066 void wxVLogVerbose(const char* formatString
, va_list argPtr
);
1069 /** @addtogroup group_funcmacro_log */
1072 For warnings - they are also normally shown to the user, but don't
1073 interrupt the program work.
1077 void wxLogWarning(const char* formatString
, ... );
1078 void wxVLogWarning(const char* formatString
, va_list argPtr
);
1081 /** @addtogroup group_funcmacro_log */
1084 Like wxLogError(), but also terminates the program with the exit code 3.
1085 Using @e abort() standard function also terminates the program with this
1090 void wxLogFatalError(const char* formatString
, ... );
1091 void wxVLogFatalError(const char* formatString
, va_list argPtr
);
1094 /** @addtogroup group_funcmacro_log */
1097 The functions to use for error messages, i.e. the messages that must be
1098 shown to the user. The default processing is to pop up a message box to
1099 inform the user about it.
1103 void wxLogError(const char* formatString
, ... );
1104 void wxVLogError(const char* formatString
, va_list argPtr
);
1107 /** @addtogroup group_funcmacro_log */
1110 Like wxLogDebug(), trace functions only do something in debug builds and
1111 expand to nothing in the release one. The reason for making it a separate
1112 function is that usually there are a lot of trace messages, so it might
1113 make sense to separate them from other debug messages.
1115 wxLogDebug(const char*,const char*,...) and
1116 wxLogDebug(wxTraceMask,const char*,...) can be used instead if you would
1117 like to be able to separate trace messages into different categories which
1118 can be enabled or disabled with the static functions provided in wxLog.
1122 void wxLogTrace(const char* formatString
, ... );
1123 void wxVLogTrace(const char* formatString
, va_list argPtr
);
1126 /** @addtogroup group_funcmacro_log */
1129 Like wxLogDebug(), trace functions only do something in debug builds and
1130 expand to nothing in the release one. The reason for making it a separate
1131 function is that usually there are a lot of trace messages, so it might
1132 make sense to separate them from other debug messages.
1134 In this version of wxLogTrace(), trace messages can be separated into
1135 different categories and calls using this function only log the message if
1136 the given @a mask is currently enabled in wxLog. This lets you selectively
1137 trace only some operations and not others by enabling the desired trace
1138 masks with wxLog::AddTraceMask() or by setting the
1139 @ref overview_envvars "@c WXTRACE environment variable".
1141 The predefined string trace masks used by wxWidgets are:
1144 @itemdef{ wxTRACE_MemAlloc, Trace memory allocation (new/delete) }
1145 @itemdef{ wxTRACE_Messages, Trace window messages/X callbacks }
1146 @itemdef{ wxTRACE_ResAlloc, Trace GDI resource allocation }
1147 @itemdef{ wxTRACE_RefCount, Trace various ref counting operations }
1148 @itemdef{ wxTRACE_OleCalls, Trace OLE method calls (Win32 only) }
1151 @note Since both the mask and the format string are strings, this might
1152 lead to function signature confusion in some cases: if you intend to
1153 call the format string only version of wxLogTrace(), add a "%s"
1154 format string parameter and then supply a second string parameter for
1155 that "%s", the string mask version of wxLogTrace() will erroneously
1156 get called instead, since you are supplying two string parameters to
1157 the function. In this case you'll unfortunately have to avoid having
1158 two leading string parameters, e.g. by adding a bogus integer (with
1159 its "%d" format string).
1163 void wxLogTrace(const char* mask
, const char* formatString
, ... );
1164 void wxVLogTrace(const char* mask
,
1165 const char* formatString
,
1169 /** @addtogroup group_funcmacro_log */
1172 Like wxLogDebug(), trace functions only do something in debug builds and
1173 expand to nothing in the release one. The reason for making it a separate
1174 function is that usually there are a lot of trace messages, so it might
1175 make sense to separate them from other debug messages.
1178 This version of wxLogTrace() only logs the message if all the bits
1179 corresponding to the @a mask are set in the wxLog trace mask which can be
1180 set by calling wxLog::SetTraceMask(). This version is less flexible than
1181 wxLogDebug(const char*,const char*,...) because it doesn't allow defining
1182 the user trace masks easily. This is why it is deprecated in favour of
1183 using string trace masks.
1185 The following bitmasks are defined for wxTraceMask:
1188 @itemdef{ wxTraceMemAlloc, Trace memory allocation (new/delete) }
1189 @itemdef{ wxTraceMessages, Trace window messages/X callbacks }
1190 @itemdef{ wxTraceResAlloc, Trace GDI resource allocation }
1191 @itemdef{ wxTraceRefCount, Trace various ref counting operations }
1192 @itemdef{ wxTraceOleCalls, Trace OLE method calls (Win32 only) }
1197 void wxLogTrace(wxTraceMask mask
, const char* formatString
, ... );
1198 void wxVLogTrace(wxTraceMask mask
, const char* formatString
, va_list argPtr
);
1201 /** @addtogroup group_funcmacro_log */
1204 The right functions for debug output. They only do something in debug mode
1205 (when the preprocessor symbol @c __WXDEBUG__ is defined) and expand to
1206 nothing in release mode (otherwise).
1210 void wxLogDebug(const char* formatString
, ... );
1211 void wxVLogDebug(const char* formatString
, va_list argPtr
);
1214 /** @addtogroup group_funcmacro_log */
1217 Messages logged by this function will appear in the statusbar of the
1218 @a frame or of the top level application window by default (i.e. when using
1219 the second version of the functions).
1221 If the target frame doesn't have a statusbar, the message will be lost.
1225 void wxLogStatus(wxFrame
* frame
, const char* formatString
, ... );
1226 void wxVLogStatus(wxFrame
* frame
, const char* formatString
, va_list argPtr
);
1227 void wxLogStatus(const char* formatString
, ... );
1228 void wxVLogStatus(const char* formatString
, va_list argPtr
);
1231 /** @addtogroup group_funcmacro_log */
1234 Mostly used by wxWidgets itself, but might be handy for logging errors
1235 after system call (API function) failure. It logs the specified message
1236 text as well as the last system error code (@e errno or @e ::GetLastError()
1237 depending on the platform) and the corresponding error message. The second
1238 form of this function takes the error code explicitly as the first
1241 @see wxSysErrorCode(), wxSysErrorMsg()
1245 void wxLogSysError(const char* formatString
, ... );
1246 void wxVLogSysError(const char* formatString
, va_list argPtr
);