1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxLogWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 This class represents a background log window: to be precise, it collects all
13 log messages in the log frame which it manages but also passes them on to the
14 log target which was active at the moment of its creation. This allows you, for
15 example, to show all the log messages in a frame but still continue to process
16 them normally by showing the standard log dialog.
23 class wxLogWindow
: public wxLogInterposer
27 Creates the log frame window and starts collecting the messages in it.
30 The parent window for the log frame, may be @NULL
32 The title for the log frame
34 @true to show the frame initially (default), otherwise
35 Show() must be called later.
37 @true to process the log messages normally in addition to
38 logging them in the log frame (default), @false to only log them in the
41 wxLogWindow(wxWindow
* pParent
, const wxString
& szTitle
, bool show
= true,
42 bool passToOld
= true);
45 Returns the associated log frame window. This may be used to position or resize
46 it but use Show() to show or hide it.
48 wxFrame
* GetFrame() const;
51 Called if the user closes the window interactively, will not be
52 called if it is destroyed for another reason (such as when program
55 Return @true from here to allow the frame to close, @false to
56 prevent this from happening.
60 virtual bool OnFrameClose(wxFrame
* frame
);
63 Called immediately after the log frame creation allowing for
64 any extra initializations.
66 virtual void OnFrameCreate(wxFrame
* frame
);
69 Called right before the log frame is going to be deleted: will
70 always be called unlike OnFrameClose().
72 virtual void OnFrameDelete(wxFrame
* frame
);
75 Shows or hides the frame.
77 void Show(bool show
= true);
83 @class wxLogInterposerTemp
85 A special version of wxLogChain which uses itself as the new log target.
86 It forwards log messages to the previously installed one in addition to
87 processing them itself. Unlike wxLogInterposer, it doesn't delete the old
88 target which means it can be used to temporarily redirect log output.
90 As per wxLogInterposer, this class must be derived from to implement
91 wxLog::DoLog and/or wxLog::DoLogString methods.
96 class wxLogInterposerTemp
: public wxLogChain
100 The default constructor installs this object as the current active log target.
102 wxLogInterposerTemp();
110 This simple class allows you to chain log sinks, that is to install a new sink but
111 keep passing log messages to the old one instead of replacing it completely as
112 wxLog::SetActiveTarget does.
114 It is especially useful when you want to divert the logs somewhere (for
115 example to a file or a log window) but also keep showing the error messages
116 using the standard dialogs as wxLogGui does by default.
121 wxLogChain *logChain = new wxLogChain(new wxLogStderr);
123 // all the log messages are sent to stderr and also processed as usually
126 // don't delete logChain directly as this would leave a dangling
127 // pointer as active log target, use SetActiveTarget() instead
128 delete wxLog::SetActiveTarget(...something else or NULL...);
134 class wxLogChain
: public wxLog
138 Sets the specified @c logger (which may be @NULL) as the default log
139 target but the log messages are also passed to the previous log target if any.
141 wxLogChain(wxLog
* logger
);
144 Destroys the previous log target.
146 virtual ~wxLogChain();
149 Detaches the old log target so it won't be destroyed when the wxLogChain object
155 Returns the pointer to the previously active log target (which may be @NULL).
157 wxLog
* GetOldLog() const;
160 Returns @true if the messages are passed to the previously active log
161 target (default) or @false if PassMessages() had been called.
163 bool IsPassingMessages() const;
166 By default, the log messages are passed to the previously active log target.
167 Calling this function with @false parameter disables this behaviour
168 (presumably temporarily, as you shouldn't use wxLogChain at all otherwise) and
169 it can be reenabled by calling it again with @a passMessages set to @true.
171 void PassMessages(bool passMessages
);
174 Sets another log target to use (may be @NULL).
176 The log target specified in the wxLogChain(wxLog*) constructor or in a
177 previous call to this function is deleted.
178 This doesn't change the old log target value (the one the messages are
179 forwarded to) which still remains the same as was active when wxLogChain
182 void SetLog(wxLog
* logger
);
190 This is the default log target for the GUI wxWidgets applications.
192 Please see @ref overview_log_customize for explanation of how to change the
195 An object of this class is used by default to show the log messages created
196 by using wxLogMessage(), wxLogError() and other logging functions. It
197 doesn't display the messages logged by them immediately however but
198 accumulates all messages logged during an event handler execution and then
199 shows them all at once when its Flush() method is called during the idle
200 time processing. This has the important advantage of showing only a single
201 dialog to the user even if several messages were logged because of a single
202 error as it often happens (e.g. a low level function could log a message
203 because it failed to open a file resulting in its caller logging another
204 message due to the failure of higher level operation requiring the use of
205 this file). If you need to force the display of all previously logged
206 messages immediately you can use wxLog::FlushActive() to force the dialog
209 Also notice that if an error message is logged when several informative
210 messages had been already logged before, the informative messages are
211 discarded on the assumption that they are not useful -- and may be
212 confusing and hence harmful -- any more after the error. The warning
213 and error messages are never discarded however and any informational
214 messages logged after the first error one are also kept (as they may
215 contain information about the error recovery). You may override DoLog()
216 method to change this behaviour.
218 At any rate, it is possible that that several messages were accumulated
219 before this class Flush() method is called. If this is the case, Flush()
220 uses a custom dialog which shows the last message directly and allows the
221 user to view the previously logged ones by expanding the "Details"
222 wxCollapsiblePane inside it. This custom dialog also provides the buttons
223 for copying the log messages to the clipboard and saving them to a file.
225 However if only a single message is present when Flush() is called, just a
226 wxMessageBox() is used to show it. This has the advantage of being closer
227 to the native behaviour but it doesn't give the user any possibility to
228 copy or save the message (except for the recent Windows versions where @c
229 Ctrl-C may be pressed in the message box to copy its contents to the
230 clipboard) so you may want to override DoShowSingleMessage() to customize
231 wxLogGui -- the dialogs sample shows how to do this.
236 class wxLogGui
: public wxLog
245 Presents the accumulated log messages, if any, to the user.
247 This method is called during the idle time and should show any messages
248 accumulated in wxLogGui#m_aMessages field to the user.
250 virtual void Flush();
254 Returns the appropriate title for the dialog.
256 The title is constructed from wxApp::GetAppDisplayName() and the
257 severity string (e.g. "error" or "warning") appropriate for the current
258 wxLogGui#m_bErrors and wxLogGui#m_bWarnings values.
260 wxString
GetTitle() const;
263 Returns wxICON_ERROR, wxICON_WARNING or wxICON_INFORMATION depending on
264 the current maximal severity.
266 This value is suitable to be used in the style parameter of
267 wxMessageBox() function.
269 int GetSeverityIcon() const;
272 Forgets all the currently stored messages.
274 If you override Flush() (and don't call the base class version), you
275 must call this method to avoid messages being logged over and over
282 Method called by Flush() to show a single log message.
284 This function can be overridden to show the message in a different way.
285 By default a simple wxMessageBox() call is used.
288 The message to show (it can contain multiple lines).
290 The suggested title for the dialog showing the message, see
293 One of @c wxICON_XXX constants, see GetSeverityIcon().
295 virtual void DoShowSingleLogMessage(const wxString
& message
,
296 const wxString
& title
,
300 Method called by Flush() to show multiple log messages.
302 This function can be overridden to show the messages in a different way.
303 By default a special log dialog showing the most recent message and
304 allowing the user to expand it to view the previously logged ones is
308 Array of messages to show; it contains more than one element.
310 Array of message severities containing @c wxLOG_XXX values.
312 Array of time_t values indicating when each message was logged.
314 The suggested title for the dialog showing the message, see
317 One of @c wxICON_XXX constants, see GetSeverityIcon().
319 virtual void DoShowMultipleLogMessages(const wxArrayString
& messages
,
320 const wxArrayInt
& severities
,
321 const wxArrayLong
& times
,
322 const wxString
& title
,
327 All currently accumulated messages.
329 This array may be empty if no messages were logged.
331 @see m_aSeverity, m_aTimes
333 wxArrayString m_aMessages
;
336 The severities of each logged message.
338 This array is synchronized with wxLogGui#m_aMessages, i.e. the n-th
339 element of this array corresponds to the severity of the n-th message.
340 The possible severity values are @c wxLOG_XXX constants, e.g.
341 wxLOG_Error, wxLOG_Warning, wxLOG_Message etc.
343 wxArrayInt m_aSeverity
;
346 The time stamps of each logged message.
348 The elements of this array are time_t values corresponding to the time
349 when the message was logged.
351 wxArrayLong m_aTimes
;
354 True if there any error messages.
359 True if there any warning messages.
361 If both wxLogGui#m_bErrors and this member are false, there are only
362 informational messages to be shown.
367 True if there any messages to be shown to the user.
369 This variable is used instead of simply checking whether
370 wxLogGui#m_aMessages array is empty to allow blocking further calls to
371 Flush() while a log dialog is already being shown, even if the messages
372 array hasn't been emptied yet.
382 This class can be used to redirect the log messages to a C++ stream.
384 Please note that this class is only available if wxWidgets was compiled with
385 the standard iostream library support (@c wxUSE_STD_IOSTREAM must be on).
390 @see wxLogStderr, wxStreamToTextRedirector
392 class wxLogStream
: public wxLog
396 Constructs a log target which sends all the log messages to the given
397 output stream. If it is @NULL, the messages are sent to @c cerr.
399 wxLogStream(std::ostream
*ostr
= NULL
);
407 This class can be used to redirect the log messages to a C file stream (not to
408 be confused with C++ streams).
410 It is the default log target for the non-GUI wxWidgets applications which
411 send all the output to @c stderr.
418 class wxLogStderr
: public wxLog
422 Constructs a log target which sends all the log messages to the given
423 @c FILE. If it is @NULL, the messages are sent to @c stderr.
425 wxLogStderr(FILE* fp
= NULL
);
433 wxLogBuffer is a very simple implementation of log sink which simply collects
434 all the logged messages in a string (except the debug messages which are output
435 in the usual way immediately as we're presumably not interested in collecting
436 them for later). The messages from different log function calls are separated
439 All the messages collected so far can be shown to the user (and the current
440 buffer cleared) by calling the overloaded wxLogBuffer::Flush method.
445 class wxLogBuffer
: public wxLog
449 The default ctor does nothing.
454 Shows all the messages collected so far to the user (using a message box in the
455 GUI applications or by printing them out to the console in text mode) and
456 clears the internal buffer.
458 virtual void Flush();
461 Returns the current buffer contains. Messages from different log function calls
462 are separated with the new lines in the buffer.
463 The buffer can be cleared by Flush() which will also show the current
464 contents to the user.
466 const wxString
& GetBuffer() const;
472 @class wxLogInterposer
474 A special version of wxLogChain which uses itself as the new log target.
475 It forwards log messages to the previously installed one in addition to
476 processing them itself.
478 Unlike wxLogChain which is usually used directly as is, this class must be
479 derived from to implement wxLog::DoLog and/or wxLog::DoLogString methods.
481 wxLogInterposer destroys the previous log target in its destructor.
482 If you don't want this to happen, use wxLogInterposerTemp instead.
487 class wxLogInterposer
: public wxLogChain
491 The default constructor installs this object as the current active log target.
501 Using these target all the log messages can be redirected to a text control.
502 The text control must have been created with @c wxTE_MULTILINE style by the
508 @see wxTextCtrl, wxStreamToTextRedirector
510 class wxLogTextCtrl
: public wxLog
514 Constructs a log target which sends all the log messages to the given text
515 control. The @a textctrl parameter cannot be @NULL.
517 wxLogTextCtrl(wxTextCtrl
* pTextCtrl
);
525 wxLog class defines the interface for the @e log targets used by wxWidgets
526 logging functions as explained in the @ref overview_log.
527 The only situations when you need to directly use this class is when you want
528 to derive your own log target because the existing ones don't satisfy your
529 needs. Another case is if you wish to customize the behaviour of the standard
530 logging classes (all of which respect the wxLog settings): for example, set
531 which trace messages are logged and which are not or change (or even remove
532 completely) the timestamp on the messages.
534 Otherwise, it is completely hidden behind the @e wxLogXXX() functions and
535 you may not even know about its existence.
537 @note For console-mode applications, the default target is wxLogStderr, so
538 that all @e wxLogXXX() functions print on @c stderr when @c wxUSE_GUI = 0.
541 @section log_derivingyours Deriving your own log target
543 There are two functions which must be implemented by any derived class to
544 actually process the log messages: DoLog() and DoLogString().
545 The second function receives a string which just has to be output in some way
546 and the easiest way to write a new log target is to override just this function
547 in the derived class.
549 If more control over the output format is needed, then the first function must
550 be overridden which allows to construct custom messages depending on the log level
551 or even do completely different things depending on the message severity
552 (for example, throw away all messages except warnings and errors, show warnings
553 on the screen and forward the error messages to the user's (or programmer's) cell
554 phone - maybe depending on whether the timestamp tells us if it is day or
555 night in the current time zone).
557 There also functions to support message buffering. Why are they needed?
558 Some of wxLog implementations, most notably the standard wxLogGui class,
559 buffer the messages (for example, to avoid showing the user a zillion of modal
560 message boxes one after another -- which would be really annoying).
562 Flush() shows them all and clears the buffer contents.
563 This function doesn't do anything if the buffer is already empty.
570 @section log_tracemasks Using trace masks
572 The functions below allow some limited customization of wxLog behaviour
573 without writing a new log target class (which, aside from being a matter of
574 several minutes, allows you to do anything you want).
575 The verbose messages are the trace messages which are not disabled in the
576 release mode and are generated by wxLogVerbose().
577 They are not normally shown to the user because they present little interest,
578 but may be activated, for example, in order to help the user find some program
581 As for the (real) trace messages, their handling depends on the settings of
582 the (application global) @e trace mask which can either be specified using
583 SetTraceMask(), GetTraceMask() and wxLogTrace() which takes an integer mask
584 or using AddTraceMask() for string trace masks.
586 The difference between bit-wise and string trace masks is that a message using
587 integer trace mask will only be logged if all bits of the mask are set in the
588 current mask while a message using string mask will be logged simply if the
589 mask had been added before to the list of allowed ones.
593 wxLogTrace( wxTraceRefCount|wxTraceOleCalls, "Active object ref count: %d", nRef );
596 will do something only if the current trace mask contains both @c wxTraceRefCount
597 and @c wxTraceOle, but:
600 wxLogTrace( wxTRACE_OleCalls, "IFoo::Bar() called" );
603 will log the message if it was preceded by:
606 wxLog::AddTraceMask( wxTRACE_OleCalls);
609 Using string masks is simpler and allows you to easily add custom ones, so this
610 is the preferred way of working with trace messages. The integer trace mask is
611 kept for compatibility and for additional (but very rarely needed) flexibility
614 The standard trace masks are given in wxLogTrace() documentation.
616 Finally, the @e wxLog::DoLog() function automatically prepends a time stamp
617 to all the messages. The format of the time stamp may be changed: it can be
618 any string with % specifications fully described in the documentation of the
619 standard @e strftime() function. For example, the default format is
620 "[%d/%b/%y %H:%M:%S] " which gives something like "[17/Sep/98 22:10:16] "
621 (without quotes) for the current date. Setting an empty string as the time
622 format or calling the shortcut wxLog::DisableTimestamp(), disables timestamping
623 of the messages completely.
627 @li RemoveTraceMask()
628 @li ClearTraceMasks()
630 @li IsAllowedTraceMask()
637 @li SetRepetitionCounting()
638 @li GetRepetitionCounting()
641 Timestamping is disabled for Visual C++ users in debug builds by
642 default because otherwise it would be impossible to directly go to the line
643 from which the log message was generated by simply clicking in the debugger
644 window on the corresponding error message. If you wish to enable it, please
645 use SetTimestamp() explicitly.
648 @section log_target Manipulating the log target
650 The functions in this section work with and manipulate the active log
651 target. The OnLog() is called by the @e wxLogXXX() functions
652 and invokes the DoLog() of the active log target if any.
654 Get/Set methods are used to install/query the current active target and,
655 finally, DontCreateOnDemand() disables the automatic creation of a standard
656 log target if none actually exists. It is only useful when the application
657 is terminating and shouldn't be used in other situations because it may
658 easily lead to a loss of messages.
662 @li GetActiveTarget()
663 @li SetActiveTarget()
664 @li DontCreateOnDemand()
672 @see @ref overview_log
678 Add the @a mask to the list of allowed masks for wxLogTrace().
680 @see RemoveTraceMask(), GetTraceMasks()
682 static void AddTraceMask(const wxString
& mask
);
685 Removes all trace masks previously set with AddTraceMask().
687 @see RemoveTraceMask()
689 static void ClearTraceMasks();
692 Instructs wxLog to not create new log targets on the fly if there is none
693 currently. (Almost) for internal use only: it is supposed to be called by the
694 application shutdown code.
696 Note that this function also calls ClearTraceMasks().
698 static void DontCreateOnDemand();
701 Shows all the messages currently in buffer and clears it.
702 If the buffer is already empty, nothing happens.
704 virtual void Flush();
707 Flushes the current log target if any, does nothing if there is none.
711 static void FlushActive();
714 Returns the pointer to the active log target (may be @NULL).
716 static wxLog
* GetActiveTarget();
719 Returns the current log level limit.
721 static wxLogLevel
GetLogLevel();
724 Returns whether the repetition counting mode is enabled.
726 static bool GetRepetitionCounting();
729 Returns the current timestamp format string.
731 static const wxString
GetTimestamp();
734 Returns the current trace mask, see Customization() section for details.
736 static wxTraceMask
GetTraceMask();
739 Returns the currently allowed list of string trace masks.
743 static const wxArrayString
GetTraceMasks();
746 Returns whether the verbose mode is currently active.
748 static bool GetVerbose();
751 Returns @true if the @a mask is one of allowed masks for wxLogTrace().
753 See also: AddTraceMask(), RemoveTraceMask()
755 static bool IsAllowedTraceMask(const wxString
& mask
);
758 Forwards the message at specified level to the @e DoLog() function of the
759 active log target if there is any, does nothing otherwise.
761 static void OnLog(wxLogLevel level
, const wxString
& message
);
764 Remove the @a mask from the list of allowed masks for
769 static void RemoveTraceMask(const wxString
& mask
);
772 Resumes logging previously suspended by a call to Suspend().
773 All messages logged in the meanwhile will be flushed soon.
775 static void Resume();
778 Sets the specified log target as the active one.
780 Returns the pointer to the previous active log target (may be @NULL).
781 To suppress logging use a new instance of wxLogNull not @NULL. If the
782 active log target is set to @NULL a new default log target will be
783 created when logging occurs.
785 static wxLog
* SetActiveTarget(wxLog
* logtarget
);
788 Specifies that log messages with level logLevel should be ignored
789 and not sent to the active log target.
791 static void SetLogLevel(wxLogLevel logLevel
);
794 Enables logging mode in which a log message is logged once, and in case exactly
795 the same message successively repeats one or more times, only the number of
796 repetitions is logged.
798 static void SetRepetitionCounting(bool repetCounting
= true);
801 Sets the timestamp format prepended by the default log targets to all
802 messages. The string may contain any normal characters as well as %
803 prefixed format specificators, see @e strftime() manual for details.
804 Passing an empty string to this function disables message time stamping.
806 static void SetTimestamp(const wxString
& format
);
809 Disables time stamping of the log messages.
813 static void DisableTimestamp();
816 Sets the trace mask, see @ref log_derivingyours section for details.
818 static void SetTraceMask(wxTraceMask mask
);
821 Activates or deactivates verbose mode in which the verbose messages are
822 logged as the normal ones instead of being silently dropped.
824 static void SetVerbose(bool verbose
= true);
827 Suspends the logging until Resume() is called.
829 Note that the latter must be called the same number of times as the former
830 to undo it, i.e. if you call Suspend() twice you must call Resume() twice as well.
832 Note that suspending the logging means that the log sink won't be be flushed
833 periodically, it doesn't have any effect if the current log target does the
834 logging immediately without waiting for Flush() to be called (the standard
835 GUI log target only shows the log dialog when it is flushed, so Suspend()
836 works as expected with it).
838 @see Resume(), wxLogNull
840 static void Suspend();
845 Called to process the message of the specified severity. @a msg is the text
846 of the message as specified in the call of @e wxLogXXX() function which
847 generated it and @a timestamp is the moment when the message was generated.
849 The base class version prepends the timestamp to the message, adds a prefix
850 corresponding to the log level and then calls
851 DoLogString() with the resulting string.
853 virtual void DoLog(wxLogLevel level
, const wxString
& msg
, time_t timestamp
);
856 Called to log the specified string. The timestamp is already included in the
857 string but still passed to this function.
859 A simple implementation may just send the string to @c stdout or, better,
862 virtual void DoLogString(const wxString
& msg
, time_t timestamp
);
870 This class allows you to temporarily suspend logging. All calls to the log
871 functions during the life time of an object of this class are just ignored.
873 In particular, it can be used to suppress the log messages given by wxWidgets
874 itself but it should be noted that it is rarely the best way to cope with this
875 problem as @b all log messages are suppressed, even if they indicate a
876 completely different error than the one the programmer wanted to suppress.
878 For instance, the example of the overview:
883 // wxFile.Open() normally complains if file can't be opened, we don't want it
886 if ( !file.Open("bar") )
887 ... process error ourselves ...
888 } // ~wxLogNull called, old log sink restored
890 wxLogMessage("..."); // ok
893 would be better written as:
898 // don't try to open file if it doesn't exist, we are prepared to deal with
899 // this ourselves - but all other errors are not expected
900 if ( wxFile::Exists("bar") )
902 // gives an error message if the file couldn't be opened
915 class wxLogNull
: public wxLog
931 // ============================================================================
932 // Global functions/macros
933 // ============================================================================
935 /** @ingroup group_funcmacro_log */
939 This function shows a message to the user in a safe way and should be safe
940 to call even before the application has been initialized or if it is
941 currently in some other strange state (for example, about to crash). Under
942 Windows this function shows a message box using a native dialog instead of
943 wxMessageBox() (which might be unsafe to call), elsewhere it simply prints
944 the message to the standard output using the title as prefix.
947 The title of the message box shown to the user or the prefix of the
950 The text to show to the user.
952 @see wxLogFatalError()
956 void wxSafeShowMessage(const wxString
& title
, const wxString
& text
);
959 Returns the error code from the last system call. This function uses
960 @c errno on Unix platforms and @c GetLastError under Win32.
962 @see wxSysErrorMsg(), wxLogSysError()
966 unsigned long wxSysErrorCode();
969 Returns the error message corresponding to the given system error code. If
970 @a errCode is 0 (default), the last error code (as returned by
971 wxSysErrorCode()) is used.
973 @see wxSysErrorCode(), wxLogSysError()
977 const wxChar
* wxSysErrorMsg(unsigned long errCode
= 0);
981 /** @ingroup group_funcmacro_log */
984 For all normal, informational messages. They also appear in a message box
985 by default (but it can be changed).
989 void wxLogMessage(const char* formatString
, ... );
990 void wxVLogMessage(const char* formatString
, va_list argPtr
);
993 /** @ingroup group_funcmacro_log */
996 For verbose output. Normally, it is suppressed, but might be activated if
997 the user wishes to know more details about the program progress (another,
998 but possibly confusing name for the same function could be @c wxLogInfo).
1002 void wxLogVerbose(const char* formatString
, ... );
1003 void wxVLogVerbose(const char* formatString
, va_list argPtr
);
1006 /** @ingroup group_funcmacro_log */
1009 For warnings - they are also normally shown to the user, but don't
1010 interrupt the program work.
1014 void wxLogWarning(const char* formatString
, ... );
1015 void wxVLogWarning(const char* formatString
, va_list argPtr
);
1018 /** @ingroup group_funcmacro_log */
1021 Like wxLogError(), but also terminates the program with the exit code 3.
1022 Using @e abort() standard function also terminates the program with this
1027 void wxLogFatalError(const char* formatString
, ... );
1028 void wxVLogFatalError(const char* formatString
, va_list argPtr
);
1031 /** @ingroup group_funcmacro_log */
1034 The functions to use for error messages, i.e. the messages that must be
1035 shown to the user. The default processing is to pop up a message box to
1036 inform the user about it.
1040 void wxLogError(const char* formatString
, ... );
1041 void wxVLogError(const char* formatString
, va_list argPtr
);
1044 /** @ingroup group_funcmacro_log */
1047 Like wxLogDebug(), trace functions only do something in debug builds and
1048 expand to nothing in the release one. The reason for making it a separate
1049 function is that usually there are a lot of trace messages, so it might
1050 make sense to separate them from other debug messages.
1052 wxLogDebug(const char*,const char*,...) and
1053 wxLogDebug(wxTraceMask,const char*,...) can be used instead if you would
1054 like to be able to separate trace messages into different categories which
1055 can be enabled or disabled with the static functions provided in wxLog.
1059 void wxLogTrace(const char* formatString
, ... );
1060 void wxVLogTrace(const char* formatString
, va_list argPtr
);
1063 /** @ingroup group_funcmacro_log */
1066 Like wxLogDebug(), trace functions only do something in debug builds and
1067 expand to nothing in the release one. The reason for making it a separate
1068 function is that usually there are a lot of trace messages, so it might
1069 make sense to separate them from other debug messages.
1071 In this version of wxLogTrace(), trace messages can be separated into
1072 different categories and calls using this function only log the message if
1073 the given @a mask is currently enabled in wxLog. This lets you selectively
1074 trace only some operations and not others by enabling the desired trace
1075 masks with wxLog::AddTraceMask() or by setting the
1076 @ref overview_envvars "@c WXTRACE environment variable".
1078 The predefined string trace masks used by wxWidgets are:
1081 @itemdef{ wxTRACE_MemAlloc, Trace memory allocation (new/delete) }
1082 @itemdef{ wxTRACE_Messages, Trace window messages/X callbacks }
1083 @itemdef{ wxTRACE_ResAlloc, Trace GDI resource allocation }
1084 @itemdef{ wxTRACE_RefCount, Trace various ref counting operations }
1085 @itemdef{ wxTRACE_OleCalls, Trace OLE method calls (Win32 only) }
1088 @note Since both the mask and the format string are strings, this might
1089 lead to function signature confusion in some cases: if you intend to
1090 call the format string only version of wxLogTrace(), add a "%s"
1091 format string parameter and then supply a second string parameter for
1092 that "%s", the string mask version of wxLogTrace() will erroneously
1093 get called instead, since you are supplying two string parameters to
1094 the function. In this case you'll unfortunately have to avoid having
1095 two leading string parameters, e.g. by adding a bogus integer (with
1096 its "%d" format string).
1100 void wxLogTrace(const char* mask
, const char* formatString
, ... );
1101 void wxVLogTrace(const char* mask
,
1102 const char* formatString
,
1106 /** @ingroup group_funcmacro_log */
1109 Like wxLogDebug(), trace functions only do something in debug builds and
1110 expand to nothing in the release one. The reason for making it a separate
1111 function is that usually there are a lot of trace messages, so it might
1112 make sense to separate them from other debug messages.
1115 This version of wxLogTrace() only logs the message if all the bits
1116 corresponding to the @a mask are set in the wxLog trace mask which can be
1117 set by calling wxLog::SetTraceMask(). This version is less flexible than
1118 wxLogDebug(const char*,const char*,...) because it doesn't allow defining
1119 the user trace masks easily. This is why it is deprecated in favour of
1120 using string trace masks.
1122 The following bitmasks are defined for wxTraceMask:
1125 @itemdef{ wxTraceMemAlloc, Trace memory allocation (new/delete) }
1126 @itemdef{ wxTraceMessages, Trace window messages/X callbacks }
1127 @itemdef{ wxTraceResAlloc, Trace GDI resource allocation }
1128 @itemdef{ wxTraceRefCount, Trace various ref counting operations }
1129 @itemdef{ wxTraceOleCalls, Trace OLE method calls (Win32 only) }
1134 void wxLogTrace(wxTraceMask mask
, const char* formatString
, ... );
1135 void wxVLogTrace(wxTraceMask mask
, const char* formatString
, va_list argPtr
);
1138 /** @ingroup group_funcmacro_log */
1141 The right functions for debug output. They only do something in debug mode
1142 (when the preprocessor symbol @c __WXDEBUG__ is defined) and expand to
1143 nothing in release mode (otherwise).
1147 void wxLogDebug(const char* formatString
, ... );
1148 void wxVLogDebug(const char* formatString
, va_list argPtr
);
1151 /** @ingroup group_funcmacro_log */
1154 Messages logged by this function will appear in the statusbar of the
1155 @a frame or of the top level application window by default (i.e. when using
1156 the second version of the functions).
1158 If the target frame doesn't have a statusbar, the message will be lost.
1162 void wxLogStatus(wxFrame
* frame
, const char* formatString
, ... );
1163 void wxVLogStatus(wxFrame
* frame
, const char* formatString
, va_list argPtr
);
1164 void wxLogStatus(const char* formatString
, ... );
1165 void wxVLogStatus(const char* formatString
, va_list argPtr
);
1168 /** @ingroup group_funcmacro_log */
1171 Mostly used by wxWidgets itself, but might be handy for logging errors
1172 after system call (API function) failure. It logs the specified message
1173 text as well as the last system error code (@e errno or @e ::GetLastError()
1174 depending on the platform) and the corresponding error message. The second
1175 form of this function takes the error code explicitly as the first
1178 @see wxSysErrorCode(), wxSysErrorMsg()
1182 void wxLogSysError(const char* formatString
, ... );
1183 void wxVLogSysError(const char* formatString
, va_list argPtr
);