1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 // ----------------------------------------------------------------------------
18 // common constants for use in wxUSE_LOG/!wxUSE_LOG
19 // ----------------------------------------------------------------------------
21 // the trace masks have been superceded by symbolic trace constants, they're
22 // for compatibility only andwill be removed soon - do NOT use them
24 // meaning of different bits of the trace mask (which allows selectively
25 // enable/disable some trace messages)
26 #define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete)
27 #define wxTraceMessages 0x0002 // trace window messages/X callbacks
28 #define wxTraceResAlloc 0x0004 // trace GDI resource allocation
29 #define wxTraceRefCount 0x0008 // trace various ref counting operations
32 #define wxTraceOleCalls 0x0100 // OLE interface calls
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 // NB: these types are needed even if wxUSE_LOG == 0
40 typedef unsigned long wxTraceMask
;
41 typedef unsigned long wxLogLevel
;
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 #include "wx/string.h"
48 #include "wx/strvararg.h"
52 #include "wx/arrstr.h"
55 #include <time.h> // for time_t
58 #include "wx/dynarray.h"
60 #ifndef wxUSE_LOG_DEBUG
62 # define wxUSE_LOG_DEBUG 1
63 # else // !__WXDEBUG__
64 # define wxUSE_LOG_DEBUG 0
68 // ----------------------------------------------------------------------------
69 // forward declarations
70 // ----------------------------------------------------------------------------
73 class WXDLLIMPEXP_CORE wxTextCtrl
;
74 class WXDLLIMPEXP_CORE wxLogFrame
;
75 class WXDLLIMPEXP_CORE wxFrame
;
76 class WXDLLIMPEXP_CORE wxWindow
;
79 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
83 // different standard log levels (you may also define your own)
86 wxLOG_FatalError
, // program can't continue, abort immediately
87 wxLOG_Error
, // a serious error, user must be informed about it
88 wxLOG_Warning
, // user is normally informed about it but may be ignored
89 wxLOG_Message
, // normal message (i.e. normal output of a non GUI app)
90 wxLOG_Status
, // informational: might go to the status line of GUI app
91 wxLOG_Info
, // informational message (a.k.a. 'Verbose')
92 wxLOG_Debug
, // never shown to the user, disabled in release mode
93 wxLOG_Trace
, // trace messages are also only enabled in debug mode
94 wxLOG_Progress
, // used for progress indicator (not yet)
95 wxLOG_User
= 100, // user defined levels start here
99 // symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
100 // discarded unless the string "foo" has been added to the list of allowed
101 // ones with AddTraceMask()
103 #define wxTRACE_MemAlloc wxT("memalloc") // trace memory allocation (new/delete)
104 #define wxTRACE_Messages wxT("messages") // trace window messages/X callbacks
105 #define wxTRACE_ResAlloc wxT("resalloc") // trace GDI resource allocation
106 #define wxTRACE_RefCount wxT("refcount") // trace various ref counting operations
109 #define wxTRACE_OleCalls wxT("ole") // OLE interface calls
112 #include "wx/iosfwrap.h"
114 // ----------------------------------------------------------------------------
115 // derive from this class to redirect (or suppress, or ...) log messages
116 // normally, only a single instance of this class exists but it's not enforced
117 // ----------------------------------------------------------------------------
119 class WXDLLIMPEXP_BASE wxLog
125 // these functions allow to completely disable all log messages
127 // is logging disabled now?
128 static bool IsEnabled() { return ms_doLog
; }
130 // change the flag state, return the previous one
131 static bool EnableLogging(bool doIt
= true)
132 { bool doLogOld
= ms_doLog
; ms_doLog
= doIt
; return doLogOld
; }
134 // static sink function - see DoLog() for function to overload in the
136 static void OnLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
140 // flush shows all messages if they're not logged immediately (FILE
141 // and iostream logs don't need it, but wxGuiLog does to avoid showing
142 // 17 modal dialogs one after another)
143 virtual void Flush();
145 // flush the active target if any
146 static void FlushActive()
148 if ( !ms_suspendCount
)
150 wxLog
*log
= GetActiveTarget();
156 // only one sink is active at each moment
157 // get current log target, will call wxApp::CreateLogTarget() to
158 // create one if none exists
159 static wxLog
*GetActiveTarget();
161 // change log target, pLogger may be NULL
162 static wxLog
*SetActiveTarget(wxLog
*pLogger
);
164 // suspend the message flushing of the main target until the next call
165 // to Resume() - this is mainly for internal use (to prevent wxYield()
166 // from flashing the messages)
167 static void Suspend() { ms_suspendCount
++; }
169 // must be called for each Suspend()!
170 static void Resume() { ms_suspendCount
--; }
172 // functions controlling the default wxLog behaviour
173 // verbose mode is activated by standard command-line '-verbose'
175 static void SetVerbose(bool bVerbose
= true) { ms_bVerbose
= bVerbose
; }
177 // Set log level. Log messages with level > logLevel will not be logged.
178 static void SetLogLevel(wxLogLevel logLevel
) { ms_logLevel
= logLevel
; }
180 // should GetActiveTarget() try to create a new log object if the
182 static void DontCreateOnDemand();
184 // Make GetActiveTarget() create a new log object again.
185 static void DoCreateOnDemand();
187 // log the count of repeating messages instead of logging the messages
189 static void SetRepetitionCounting(bool bRepetCounting
= true)
190 { ms_bRepetCounting
= bRepetCounting
; }
192 // gets duplicate counting status
193 static bool GetRepetitionCounting() { return ms_bRepetCounting
; }
195 // trace mask (see wxTraceXXX constants for details)
196 static void SetTraceMask(wxTraceMask ulMask
) { ms_ulTraceMask
= ulMask
; }
198 // add string trace mask
199 static void AddTraceMask(const wxString
& str
)
200 { ms_aTraceMasks
.push_back(str
); }
202 // add string trace mask
203 static void RemoveTraceMask(const wxString
& str
);
205 // remove all string trace masks
206 static void ClearTraceMasks();
208 // get string trace masks
209 static const wxArrayString
&GetTraceMasks() { return ms_aTraceMasks
; }
211 // sets the timestamp string: this is used as strftime() format string
212 // for the log targets which add time stamps to the messages - set it
213 // to NULL to disable time stamping completely.
214 static void SetTimestamp(const wxString
& ts
) { ms_timestamp
= ts
; }
219 // gets the verbose status
220 static bool GetVerbose() { return ms_bVerbose
; }
223 static wxTraceMask
GetTraceMask() { return ms_ulTraceMask
; }
225 // is this trace mask in the list?
226 static bool IsAllowedTraceMask(const wxString
& mask
);
228 // return the current loglevel limit
229 static wxLogLevel
GetLogLevel() { return ms_logLevel
; }
231 // get the current timestamp format string (may be NULL)
232 static const wxString
& GetTimestamp() { return ms_timestamp
; }
237 // put the time stamp into the string if ms_timestamp != NULL (don't
238 // change it otherwise)
239 static void TimeStamp(wxString
*str
);
241 // make dtor virtual for all derived classes
245 // this method exists for backwards compatibility only, don't use
246 bool HasPendingMessages() const { return true; }
248 #if WXWIN_COMPATIBILITY_2_6
249 // this function doesn't do anything any more, don't call it
250 wxDEPRECATED( static wxChar
*SetLogBuffer(wxChar
*buf
, size_t size
= 0) );
254 // the logging functions that can be overriden
256 // default DoLog() prepends the time stamp and a prefix corresponding
257 // to the message to szString and then passes it to DoLogString()
258 virtual void DoLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
259 #if WXWIN_COMPATIBILITY_2_8
260 // these shouldn't be used by new code
261 wxDEPRECATED_BUT_USED_INTERNALLY(
262 virtual void DoLog(wxLogLevel level
, const char *szString
, time_t t
)
265 wxDEPRECATED_BUT_USED_INTERNALLY(
266 virtual void DoLog(wxLogLevel level
, const wchar_t *wzString
, time_t t
)
268 #endif // WXWIN_COMPATIBILITY_2_8
270 void LogString(const wxString
& szString
, time_t t
)
271 { DoLogString(szString
, t
); }
273 // default DoLogString does nothing but is not pure virtual because if
274 // you override DoLog() you might not need it at all
275 virtual void DoLogString(const wxString
& szString
, time_t t
);
276 #if WXWIN_COMPATIBILITY_2_8
277 // these shouldn't be used by new code
278 virtual void DoLogString(const char *WXUNUSED(szString
),
279 time_t WXUNUSED(t
)) {}
280 virtual void DoLogString(const wchar_t *WXUNUSED(szString
),
281 time_t WXUNUSED(t
)) {}
284 // log a line containing the number of times the previous message was
286 // returns: the number
287 static unsigned DoLogNumberOfRepeats();
293 // traditional behaviour or counting repetitions
294 static bool ms_bRepetCounting
;
295 static wxString ms_prevString
; // previous message that was logged
296 // how many times the previous message was logged
297 static unsigned ms_prevCounter
;
298 static time_t ms_prevTimeStamp
;// timestamp of the previous message
299 static wxLogLevel ms_prevLevel
; // level of the previous message
301 static wxLog
*ms_pLogger
; // currently active log sink
302 static bool ms_doLog
; // false => all logging disabled
303 static bool ms_bAutoCreate
; // create new log targets on demand?
304 static bool ms_bVerbose
; // false => ignore LogInfo messages
306 static wxLogLevel ms_logLevel
; // limit logging to levels <= ms_logLevel
308 static size_t ms_suspendCount
; // if positive, logs are not flushed
310 // format string for strftime(), if NULL, time stamping log messages is
312 static wxString ms_timestamp
;
314 static wxTraceMask ms_ulTraceMask
; // controls wxLogTrace behaviour
315 static wxArrayString ms_aTraceMasks
; // more powerful filter for wxLogTrace
318 // ----------------------------------------------------------------------------
319 // "trivial" derivations of wxLog
320 // ----------------------------------------------------------------------------
322 // log everything to a buffer
323 class WXDLLIMPEXP_BASE wxLogBuffer
: public wxLog
328 // get the string contents with all messages logged
329 const wxString
& GetBuffer() const { return m_str
; }
331 // show the buffer contents to the user in the best possible way (this uses
332 // wxMessageOutputMessageBox) and clear it
333 virtual void Flush();
336 virtual void DoLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
337 virtual void DoLogString(const wxString
& szString
, time_t t
);
342 DECLARE_NO_COPY_CLASS(wxLogBuffer
)
346 // log everything to a "FILE *", stderr by default
347 class WXDLLIMPEXP_BASE wxLogStderr
: public wxLog
350 // redirect log output to a FILE
351 wxLogStderr(FILE *fp
= (FILE *) NULL
);
354 // implement sink function
355 virtual void DoLogString(const wxString
& szString
, time_t t
);
359 DECLARE_NO_COPY_CLASS(wxLogStderr
)
362 #if wxUSE_STD_IOSTREAM
364 // log everything to an "ostream", cerr by default
365 class WXDLLIMPEXP_BASE wxLogStream
: public wxLog
368 // redirect log output to an ostream
369 wxLogStream(wxSTD ostream
*ostr
= (wxSTD ostream
*) NULL
);
372 // implement sink function
373 virtual void DoLogString(const wxString
& szString
, time_t t
);
375 // using ptr here to avoid including <iostream.h> from this file
376 wxSTD ostream
*m_ostr
;
379 #endif // wxUSE_STD_IOSTREAM
381 // ----------------------------------------------------------------------------
382 // /dev/null log target: suppress logging until this object goes out of scope
383 // ----------------------------------------------------------------------------
391 // wxFile.Open() normally complains if file can't be opened, we don't
395 if ( !file.Open("bar") )
396 ... process error ourselves ...
398 // ~wxLogNull called, old log sink restored
401 class WXDLLIMPEXP_BASE wxLogNull
404 wxLogNull() : m_flagOld(wxLog::EnableLogging(false)) { }
405 ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld
); }
408 bool m_flagOld
; // the previous value of the wxLog::ms_doLog
411 // ----------------------------------------------------------------------------
412 // chaining log target: installs itself as a log target and passes all
413 // messages to the real log target given to it in the ctor but also forwards
414 // them to the previously active one
416 // note that you don't have to call SetActiveTarget() with this class, it
417 // does it itself in its ctor
418 // ----------------------------------------------------------------------------
420 class WXDLLIMPEXP_BASE wxLogChain
: public wxLog
423 wxLogChain(wxLog
*logger
);
424 virtual ~wxLogChain();
426 // change the new log target
427 void SetLog(wxLog
*logger
);
429 // this can be used to temporarily disable (and then reenable) passing
430 // messages to the old logger (by default we do pass them)
431 void PassMessages(bool bDoPass
) { m_bPassMessages
= bDoPass
; }
433 // are we passing the messages to the previous log target?
434 bool IsPassingMessages() const { return m_bPassMessages
; }
436 // return the previous log target (may be NULL)
437 wxLog
*GetOldLog() const { return m_logOld
; }
439 // override base class version to flush the old logger as well
440 virtual void Flush();
443 // pass the chain to the old logger if needed
444 virtual void DoLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
447 // the current log target
450 // the previous log target
453 // do we pass the messages to the old logger?
454 bool m_bPassMessages
;
456 DECLARE_NO_COPY_CLASS(wxLogChain
)
459 // a chain log target which uses itself as the new logger
460 class WXDLLIMPEXP_BASE wxLogPassThrough
: public wxLogChain
466 DECLARE_NO_COPY_CLASS(wxLogPassThrough
)
470 // include GUI log targets:
471 #include "wx/generic/logg.h"
474 // ============================================================================
476 // ============================================================================
478 // ----------------------------------------------------------------------------
479 // Log functions should be used by application instead of stdio, iostream &c
480 // for log messages for easy redirection
481 // ----------------------------------------------------------------------------
483 // ----------------------------------------------------------------------------
484 // get error code/error message from system in a portable way
485 // ----------------------------------------------------------------------------
487 // return the last system error code
488 WXDLLIMPEXP_BASE
unsigned long wxSysErrorCode();
490 // return the error message for given (or last if 0) error code
491 WXDLLIMPEXP_BASE
const wxChar
* wxSysErrorMsg(unsigned long nErrCode
= 0);
493 // ----------------------------------------------------------------------------
494 // define wxLog<level>
495 // ----------------------------------------------------------------------------
497 #define DECLARE_LOG_FUNCTION(level) \
498 extern void WXDLLIMPEXP_BASE \
499 wxDoLog##level##Wchar(const wxChar *format, ...); \
500 extern void WXDLLIMPEXP_BASE \
501 wxDoLog##level##Utf8(const char *format, ...); \
502 WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
503 1, (const wxFormatString&), \
504 wxDoLog##level##Wchar, wxDoLog##level##Utf8) \
505 DECLARE_LOG_FUNCTION_WATCOM(level) \
506 extern void WXDLLIMPEXP_BASE wxVLog##level(const wxString& format, \
510 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351;
511 // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
512 // something too big for Borland C++ to handle
513 #define DECLARE_LOG_FUNCTION_WATCOM(level) \
514 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
515 1, (const wxString&), \
516 (wxFormatString(f1))) \
517 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
518 1, (const wxCStrData&), \
519 (wxFormatString(f1))) \
520 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
522 (wxFormatString(f1))) \
523 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
524 1, (const wchar_t*), \
525 (wxFormatString(f1)))
527 #define DECLARE_LOG_FUNCTION_WATCOM(level)
531 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
532 extern void expdecl wxDoLog##level##Wchar(argclass arg, \
533 const wxChar *format, ...); \
534 extern void expdecl wxDoLog##level##Utf8(argclass arg, \
535 const char *format, ...); \
536 WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
537 2, (argclass, const wxFormatString&), \
538 wxDoLog##level##Wchar, wxDoLog##level##Utf8) \
539 DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \
540 extern void expdecl wxVLog##level(argclass arg, \
541 const wxString& format, \
545 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351;
546 // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
547 // something too big for Borland C++ to handle
548 #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \
549 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
550 2, (argclass, const wxString&), \
551 (f1, wxFormatString(f2))) \
552 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
553 2, (argclass, const wxCStrData&), \
554 (f1, wxFormatString(f2))) \
555 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
556 2, (argclass, const char*), \
557 (f1, wxFormatString(f2))) \
558 WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
559 2, (argclass, const wchar_t*), \
560 (f1, wxFormatString(f2)))
562 #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl)
569 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
570 #define WX_WATCOM_ONLY_CODE( x ) x
572 #define WX_WATCOM_ONLY_CODE( x )
575 // log functions do nothing at all
576 #define DECLARE_LOG_FUNCTION(level) \
577 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxString&)) \
578 WX_WATCOM_ONLY_CODE( \
579 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const char*)) \
580 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wchar_t*)) \
581 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxCStrData&)) \
583 inline void wxVLog##level(const wxString& WXUNUSED(format), \
584 va_list WXUNUSED(argptr)) { } \
586 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
587 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxString&)) \
588 WX_WATCOM_ONLY_CODE( \
589 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const char*)) \
590 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wchar_t*)) \
591 WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \
593 inline void wxVLog##level(argclass WXUNUSED(arg), \
594 const wxString& WXUNUSED(format), \
595 va_list WXUNUSED(argptr)) {}
597 // Empty Class to fake wxLogNull
598 class WXDLLIMPEXP_BASE wxLogNull
604 // Dummy macros to replace some functions.
605 #define wxSysErrorCode() (unsigned long)0
606 #define wxSysErrorMsg( X ) (const wxChar*)NULL
608 // Fake symbolic trace masks... for those that are used frequently
609 #define wxTRACE_OleCalls wxEmptyString // OLE interface calls
611 #endif // wxUSE_LOG/!wxUSE_LOG
613 #define DECLARE_LOG_FUNCTION2(level, argclass, arg) \
614 DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, WXDLLIMPEXP_BASE)
616 // VC6 produces a warning if we a macro expanding to nothing to
617 // DECLARE_LOG_FUNCTION2:
618 #if defined(__VISUALC__) && __VISUALC__ < 1300
619 // "not enough actual parameters for macro 'DECLARE_LOG_FUNCTION2_EXP'"
620 #pragma warning(disable:4003)
623 // a generic function for all levels (level is passes as parameter)
624 DECLARE_LOG_FUNCTION2(Generic
, wxLogLevel
, level
);
626 // one function per each level
627 DECLARE_LOG_FUNCTION(FatalError
);
628 DECLARE_LOG_FUNCTION(Error
);
629 DECLARE_LOG_FUNCTION(Warning
);
630 DECLARE_LOG_FUNCTION(Message
);
631 DECLARE_LOG_FUNCTION(Info
);
632 DECLARE_LOG_FUNCTION(Verbose
);
634 // this function sends the log message to the status line of the top level
635 // application frame, if any
636 DECLARE_LOG_FUNCTION(Status
);
639 // this one is the same as previous except that it allows to explicitly
640 class WXDLLEXPORT wxFrame
;
641 // specify the frame to which the output should go
642 DECLARE_LOG_FUNCTION2_EXP(Status
, wxFrame
*, pFrame
, WXDLLIMPEXP_CORE
);
645 // additional one: as wxLogError, but also logs last system call error code
646 // and the corresponding error message if available
647 DECLARE_LOG_FUNCTION(SysError
);
649 // and another one which also takes the error code (for those broken APIs
650 // that don't set the errno (like registry APIs in Win32))
651 DECLARE_LOG_FUNCTION2(SysError
, long, lErrCode
);
653 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
654 DECLARE_LOG_FUNCTION2(SysError
, unsigned long, lErrCode
);
657 // debug functions do nothing in release mode
658 #if wxUSE_LOG && wxUSE_LOG_DEBUG
659 DECLARE_LOG_FUNCTION(Debug
);
661 // there is no more unconditional LogTrace: it is not different from
662 // LogDebug and it creates overload ambiguities
663 //DECLARE_LOG_FUNCTION(Trace);
665 // this version only logs the message if the mask had been added to the
666 // list of masks with AddTraceMask()
667 DECLARE_LOG_FUNCTION2(Trace
, const wxString
&, mask
);
669 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
670 DECLARE_LOG_FUNCTION2(Trace
, const char*, mask
);
671 DECLARE_LOG_FUNCTION2(Trace
, const wchar_t*, mask
);
674 // and this one does nothing if all of level bits are not set in
675 // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
676 // string identifiers
677 DECLARE_LOG_FUNCTION2(Trace
, wxTraceMask
, mask
);
679 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
680 DECLARE_LOG_FUNCTION2(Trace
, int, mask
);
682 #else //!debug || !wxUSE_LOG
683 // these functions do nothing in release builds, but don't define them as
684 // nothing as it could result in different code structure in debug and
685 // release and this could result in trouble when these macros are used
688 // note that making wxVLogDebug/Trace() themselves (empty inline) functions
689 // is a bad idea as some compilers are stupid enough to not inline even
690 // empty functions if their parameters are complicated enough, but by
691 // defining them as an empty inline function we ensure that even dumbest
692 // compilers optimise them away
693 inline void wxLogNop() { }
695 #define wxVLogDebug(fmt, valist) wxLogNop()
696 #define wxVLogTrace(mask, fmt, valist) wxLogNop()
698 #ifdef HAVE_VARIADIC_MACROS
699 // unlike the inline functions below, this completely removes the
700 // wxLogXXX calls from the object file:
701 #define wxLogDebug(fmt, ...) wxLogNop()
702 #define wxLogTrace(mask, fmt, ...) wxLogNop()
703 #else // !HAVE_VARIADIC_MACROS
704 //inline void wxLogDebug(const wxString& fmt, ...) {}
705 WX_DEFINE_VARARG_FUNC_NOP(wxLogDebug
, 1, (const wxString
&))
706 //inline void wxLogTrace(wxTraceMask, const wxString& fmt, ...) {}
707 //inline void wxLogTrace(const wxString&, const wxString& fmt, ...) {}
708 WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace
, 2, (wxTraceMask
, const wxString
&))
709 WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace
, 2, (const wxString
&, const wxString
&))
711 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
712 WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace
, 2, (const char*, const char*))
713 WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace
, 2, (const wchar_t*, const wchar_t*))
715 #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS
716 #endif // debug/!debug
718 #if defined(__VISUALC__) && __VISUALC__ < 1300
719 #pragma warning(default:4003)
722 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
723 // i.e. without using wxMessageBox() for example because it could crash
724 void WXDLLIMPEXP_BASE
725 wxSafeShowMessage(const wxString
& title
, const wxString
& text
);
727 // ----------------------------------------------------------------------------
728 // debug only logging functions: use them with API name and error code
729 // ----------------------------------------------------------------------------
732 // make life easier for people using VC++ IDE: clicking on the message
733 // will take us immediately to the place of the failed API
735 #define wxLogApiError(api, rc) \
736 wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."), \
737 __FILE__, __LINE__, api, \
738 (long)rc, wxSysErrorMsg(rc))
740 #define wxLogApiError(api, rc) \
741 wxLogDebug(wxT("In file %s at line %d: '%s' failed with ") \
742 wxT("error 0x%08lx (%s)."), \
743 __FILE__, __LINE__, api, \
744 (long)rc, wxSysErrorMsg(rc))
747 #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
750 #define wxLogApiError(api, err) wxLogNop()
751 #define wxLogLastError(api) wxLogNop()
752 #endif //debug/!debug
754 // wxCocoa has additiional trace masks
755 #if defined(__WXCOCOA__)
756 #include "wx/cocoa/log.h"
759 #ifdef WX_WATCOM_ONLY_CODE
760 #undef WX_WATCOM_ONLY_CODE