1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/log.h
3 // Purpose:     Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author:      Vadim Zeitlin
5 // Modified by:
6 // Created:     29/01/98
7 // RCS-ID:      $Id: log.h 50993 2008-01-02 21:18:15Z VZ $
8 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence:     wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef _WX_LOG_H_
13 #define _WX_LOG_H_
14 
15 #include "wx/defs.h"
16 
17 // ----------------------------------------------------------------------------
18 // common constants for use in wxUSE_LOG/!wxUSE_LOG
19 // ----------------------------------------------------------------------------
20 
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
23 
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
30 
31 #ifdef  __WXMSW__
32     #define wxTraceOleCalls 0x0100  // OLE interface calls
33 #endif
34 
35 // ----------------------------------------------------------------------------
36 // types
37 // ----------------------------------------------------------------------------
38 
39 // NB: these types are needed even if wxUSE_LOG == 0
40 typedef unsigned long wxTraceMask;
41 typedef unsigned long wxLogLevel;
42 
43 // ----------------------------------------------------------------------------
44 // headers
45 // ----------------------------------------------------------------------------
46 
47 #include "wx/string.h"
48 
49 #if wxUSE_LOG
50 
51 #include "wx/arrstr.h"
52 
53 #ifndef __WXWINCE__
54     #include <time.h>   // for time_t
55 #endif
56 
57 #include "wx/dynarray.h"
58 
59 #ifndef wxUSE_LOG_DEBUG
60 #  ifdef __WXDEBUG__
61 #    define wxUSE_LOG_DEBUG 1
62 #  else // !__WXDEBUG__
63 #    define wxUSE_LOG_DEBUG 0
64 #  endif
65 #endif
66 
67 // ----------------------------------------------------------------------------
68 // forward declarations
69 // ----------------------------------------------------------------------------
70 
71 #if wxUSE_GUI
72     class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
73     class WXDLLIMPEXP_FWD_CORE wxLogFrame;
74     class WXDLLIMPEXP_FWD_CORE wxFrame;
75     class WXDLLIMPEXP_FWD_CORE wxWindow;
76 #endif // wxUSE_GUI
77 
78 // ----------------------------------------------------------------------------
79 // constants
80 // ----------------------------------------------------------------------------
81 
82 // different standard log levels (you may also define your own)
83 enum
84 {
85     wxLOG_FatalError, // program can't continue, abort immediately
86     wxLOG_Error,      // a serious error, user must be informed about it
87     wxLOG_Warning,    // user is normally informed about it but may be ignored
88     wxLOG_Message,    // normal message (i.e. normal output of a non GUI app)
89     wxLOG_Status,     // informational: might go to the status line of GUI app
90     wxLOG_Info,       // informational message (a.k.a. 'Verbose')
91     wxLOG_Debug,      // never shown to the user, disabled in release mode
92     wxLOG_Trace,      // trace messages are also only enabled in debug mode
93     wxLOG_Progress,   // used for progress indicator (not yet)
94     wxLOG_User = 100, // user defined levels start here
95     wxLOG_Max = 10000
96 };
97 
98 // symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
99 // discarded unless the string "foo" has been added to the list of allowed
100 // ones with AddTraceMask()
101 
102 #define wxTRACE_MemAlloc wxT("memalloc") // trace memory allocation (new/delete)
103 #define wxTRACE_Messages wxT("messages") // trace window messages/X callbacks
104 #define wxTRACE_ResAlloc wxT("resalloc") // trace GDI resource allocation
105 #define wxTRACE_RefCount wxT("refcount") // trace various ref counting operations
106 
107 #ifdef  __WXMSW__
108     #define wxTRACE_OleCalls wxT("ole")  // OLE interface calls
109 #endif
110 
111 #include "wx/iosfwrap.h"
112 
113 // ----------------------------------------------------------------------------
114 // derive from this class to redirect (or suppress, or ...) log messages
115 // normally, only a single instance of this class exists but it's not enforced
116 // ----------------------------------------------------------------------------
117 
118 class WXDLLIMPEXP_BASE wxLog
119 {
120 public:
121     // ctor
wxLog()122     wxLog(){}
123 
124     // these functions allow to completely disable all log messages
125 
126     // is logging disabled now?
IsEnabled()127     static bool IsEnabled() { return ms_doLog; }
128 
129     // change the flag state, return the previous one
130     static bool EnableLogging(bool doIt = true)
131         { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; }
132 
133     // static sink function - see DoLog() for function to overload in the
134     // derived classes
135     static void OnLog(wxLogLevel level, const wxChar *szString, time_t t);
136 
137     // message buffering
138 
139     // flush shows all messages if they're not logged immediately (FILE
140     // and iostream logs don't need it, but wxGuiLog does to avoid showing
141     // 17 modal dialogs one after another)
142     virtual void Flush();
143 
144     // flush the active target if any
FlushActive()145     static void FlushActive()
146     {
147         if ( !ms_suspendCount )
148         {
149             wxLog *log = GetActiveTarget();
150             if ( log )
151                 log->Flush();
152         }
153     }
154 
155     // only one sink is active at each moment
156     // get current log target, will call wxApp::CreateLogTarget() to
157     // create one if none exists
158     static wxLog *GetActiveTarget();
159 
160     // change log target, pLogger may be NULL
161     static wxLog *SetActiveTarget(wxLog *pLogger);
162 
163     // suspend the message flushing of the main target until the next call
164     // to Resume() - this is mainly for internal use (to prevent wxYield()
165     // from flashing the messages)
Suspend()166     static void Suspend() { ms_suspendCount++; }
167 
168     // must be called for each Suspend()!
Resume()169     static void Resume() { ms_suspendCount--; }
170 
171     // functions controlling the default wxLog behaviour
172     // verbose mode is activated by standard command-line '-verbose'
173     // option
174     static void SetVerbose(bool bVerbose = true) { ms_bVerbose = bVerbose; }
175 
176     // Set log level.  Log messages with level > logLevel will not be logged.
SetLogLevel(wxLogLevel logLevel)177     static void SetLogLevel(wxLogLevel logLevel) { ms_logLevel = logLevel; }
178 
179 #if wxABI_VERSION >= 20805 /* 2.8.5+ only */
180     // should GetActiveTarget() try to create a new log object if the
181     // current is NULL?
182     static void DontCreateOnDemand();
183 #endif
184 
185     // Make GetActiveTarget() create a new log object again.
186     static void DoCreateOnDemand();
187 
188     // log the count of repeating messages instead of logging the messages
189     // multiple times
190     static void SetRepetitionCounting(bool bRepetCounting = true)
191         { ms_bRepetCounting = bRepetCounting; }
192 
193     // gets duplicate counting status
GetRepetitionCounting()194     static bool GetRepetitionCounting() { return ms_bRepetCounting; }
195 
196     // trace mask (see wxTraceXXX constants for details)
SetTraceMask(wxTraceMask ulMask)197     static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
198 
199     // add string trace mask
AddTraceMask(const wxString & str)200     static void AddTraceMask(const wxString& str)
201         { ms_aTraceMasks.push_back(str); }
202 
203     // add string trace mask
204     static void RemoveTraceMask(const wxString& str);
205 
206     // remove all string trace masks
207     static void ClearTraceMasks();
208 
209     // get string trace masks
GetTraceMasks()210     static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; }
211 
212     // sets the timestamp string: this is used as strftime() format string
213     // for the log targets which add time stamps to the messages - set it
214     // to NULL to disable time stamping completely.
SetTimestamp(const wxChar * ts)215     static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; }
216 
217 
218     // accessors
219 
220     // gets the verbose status
GetVerbose()221     static bool GetVerbose() { return ms_bVerbose; }
222 
223     // get trace mask
GetTraceMask()224     static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
225 
226     // is this trace mask in the list?
227     static bool IsAllowedTraceMask(const wxChar *mask);
228 
229     // return the current loglevel limit
GetLogLevel()230     static wxLogLevel GetLogLevel() { return ms_logLevel; }
231 
232     // get the current timestamp format string (may be NULL)
GetTimestamp()233     static const wxChar *GetTimestamp() { return ms_timestamp; }
234 
235 
236     // helpers
237 
238     // put the time stamp into the string if ms_timestamp != NULL (don't
239     // change it otherwise)
240     static void TimeStamp(wxString *str);
241 
242     // make dtor virtual for all derived classes
243     virtual ~wxLog();
244 
245 
246     // this method exists for backwards compatibility only, don't use
HasPendingMessages()247     bool HasPendingMessages() const { return true; }
248 
249 #if WXWIN_COMPATIBILITY_2_6
250     // this function doesn't do anything any more, don't call it
251     wxDEPRECATED( static wxChar *SetLogBuffer(wxChar *buf, size_t size = 0) );
252 #endif
253 
254 protected:
255     // the logging functions that can be overriden
256 
257     // default DoLog() prepends the time stamp and a prefix corresponding
258     // to the message to szString and then passes it to DoLogString()
259     virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
260 
261     // default DoLogString does nothing but is not pure virtual because if
262     // you override DoLog() you might not need it at all
263     virtual void DoLogString(const wxChar *szString, time_t t);
264 
265     // log a line containing the number of times the previous message was
266     // repeated and returns this number (which can be 0)
267     static unsigned DoLogNumberOfRepeats();
268 
269 private:
270     // static variables
271     // ----------------
272 
273     // traditional behaviour or counting repetitions
274     static bool        ms_bRepetCounting;
275     static wxString    ms_prevString;   // previous message that was logged
276     // how many times the previous message was logged
277     static unsigned    ms_prevCounter;
278     static time_t      ms_prevTimeStamp;// timestamp of the previous message
279     static wxLogLevel  ms_prevLevel;    // level of the previous message
280 
281     static wxLog      *ms_pLogger;      // currently active log sink
282     static bool        ms_doLog;        // false => all logging disabled
283     static bool        ms_bAutoCreate;  // create new log targets on demand?
284     static bool        ms_bVerbose;     // false => ignore LogInfo messages
285 
286     static wxLogLevel  ms_logLevel;     // limit logging to levels <= ms_logLevel
287 
288     static size_t      ms_suspendCount; // if positive, logs are not flushed
289 
290     // format string for strftime(), if NULL, time stamping log messages is
291     // disabled
292     static const wxChar *ms_timestamp;
293 
294     static wxTraceMask ms_ulTraceMask;   // controls wxLogTrace behaviour
295     static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
296 
297 
298     // this is the replacement of DoLogNumberOfRepeats() (which has to be kept
299     // to avoid breaking ABI in this version)
300     unsigned LogLastRepeatIfNeeded();
301 
302     // implementation of the function above which supposes that the caller had
303     // already locked gs_prevCS
304     unsigned LogLastRepeatIfNeededUnlocked();
305 };
306 
307 // ----------------------------------------------------------------------------
308 // "trivial" derivations of wxLog
309 // ----------------------------------------------------------------------------
310 
311 // log everything to a buffer
312 class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog
313 {
314 public:
wxLogBuffer()315     wxLogBuffer() { }
316 
317     // get the string contents with all messages logged
GetBuffer()318     const wxString& GetBuffer() const { return m_str; }
319 
320     // show the buffer contents to the user in the best possible way (this uses
321     // wxMessageOutputMessageBox) and clear it
322     virtual void Flush();
323 
324 protected:
325     virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
326     virtual void DoLogString(const wxChar *szString, time_t t);
327 
328 private:
329     wxString m_str;
330 
331     DECLARE_NO_COPY_CLASS(wxLogBuffer)
332 };
333 
334 
335 // log everything to a "FILE *", stderr by default
336 class WXDLLIMPEXP_BASE wxLogStderr : public wxLog
337 {
338 public:
339     // redirect log output to a FILE
340     wxLogStderr(FILE *fp = (FILE *) NULL);
341 
342 protected:
343     // implement sink function
344     virtual void DoLogString(const wxChar *szString, time_t t);
345 
346     FILE *m_fp;
347 
348     DECLARE_NO_COPY_CLASS(wxLogStderr)
349 };
350 
351 #if wxUSE_STD_IOSTREAM
352 
353 // log everything to an "ostream", cerr by default
354 class WXDLLIMPEXP_BASE wxLogStream : public wxLog
355 {
356 public:
357     // redirect log output to an ostream
358     wxLogStream(wxSTD ostream *ostr = (wxSTD ostream *) NULL);
359 
360 protected:
361     // implement sink function
362     virtual void DoLogString(const wxChar *szString, time_t t);
363 
364     // using ptr here to avoid including <iostream.h> from this file
365     wxSTD ostream *m_ostr;
366 };
367 
368 #endif // wxUSE_STD_IOSTREAM
369 
370 // ----------------------------------------------------------------------------
371 // /dev/null log target: suppress logging until this object goes out of scope
372 // ----------------------------------------------------------------------------
373 
374 // example of usage:
375 /*
376     void Foo()
377     {
378         wxFile file;
379 
380         // wxFile.Open() normally complains if file can't be opened, we don't
381         // want it
382         wxLogNull logNo;
383 
384         if ( !file.Open("bar") )
385             ... process error ourselves ...
386 
387         // ~wxLogNull called, old log sink restored
388     }
389  */
390 class WXDLLIMPEXP_BASE wxLogNull
391 {
392 public:
wxLogNull()393     wxLogNull() : m_flagOld(wxLog::EnableLogging(false)) { }
~wxLogNull()394     ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
395 
396 private:
397     bool m_flagOld; // the previous value of the wxLog::ms_doLog
398 };
399 
400 // ----------------------------------------------------------------------------
401 // chaining log target: installs itself as a log target and passes all
402 // messages to the real log target given to it in the ctor but also forwards
403 // them to the previously active one
404 //
405 // note that you don't have to call SetActiveTarget() with this class, it
406 // does it itself in its ctor
407 // ----------------------------------------------------------------------------
408 
409 class WXDLLIMPEXP_BASE wxLogChain : public wxLog
410 {
411 public:
412     wxLogChain(wxLog *logger);
413     virtual ~wxLogChain();
414 
415     // change the new log target
416     void SetLog(wxLog *logger);
417 
418     // this can be used to temporarily disable (and then reenable) passing
419     // messages to the old logger (by default we do pass them)
PassMessages(bool bDoPass)420     void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
421 
422     // are we passing the messages to the previous log target?
IsPassingMessages()423     bool IsPassingMessages() const { return m_bPassMessages; }
424 
425     // return the previous log target (may be NULL)
GetOldLog()426     wxLog *GetOldLog() const { return m_logOld; }
427 
428     // override base class version to flush the old logger as well
429     virtual void Flush();
430 
431     // call to avoid destroying the old log target
432 #if wxABI_VERSION >= 20805 /* 2.8.5+ only */
DetachOldLog()433     void DetachOldLog() { m_logOld = NULL; }
434 #endif
435 
436 protected:
437     // pass the chain to the old logger if needed
438     virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
439 
440 private:
441     // the current log target
442     wxLog *m_logNew;
443 
444     // the previous log target
445     wxLog *m_logOld;
446 
447     // do we pass the messages to the old logger?
448     bool m_bPassMessages;
449 
450     DECLARE_NO_COPY_CLASS(wxLogChain)
451 };
452 
453 // a chain log target which uses itself as the new logger
454 class WXDLLIMPEXP_BASE wxLogPassThrough : public wxLogChain
455 {
456 public:
457     wxLogPassThrough();
458 
459 private:
460     DECLARE_NO_COPY_CLASS(wxLogPassThrough)
461 };
462 
463 #if wxUSE_GUI
464     // include GUI log targets:
465     #include "wx/generic/logg.h"
466 #endif // wxUSE_GUI
467 
468 // ============================================================================
469 // global functions
470 // ============================================================================
471 
472 // ----------------------------------------------------------------------------
473 // Log functions should be used by application instead of stdio, iostream &c
474 // for log messages for easy redirection
475 // ----------------------------------------------------------------------------
476 
477 // ----------------------------------------------------------------------------
478 // get error code/error message from system in a portable way
479 // ----------------------------------------------------------------------------
480 
481 // return the last system error code
482 WXDLLIMPEXP_BASE unsigned long wxSysErrorCode();
483 
484 // return the error message for given (or last if 0) error code
485 WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
486 
487 // ----------------------------------------------------------------------------
488 // define wxLog<level>
489 // ----------------------------------------------------------------------------
490 
491 #define DECLARE_LOG_FUNCTION(level)                                         \
492 extern void WXDLLIMPEXP_BASE wxVLog##level(const wxChar *szFormat,          \
493                                            va_list argptr);                 \
494 extern void WXDLLIMPEXP_BASE wxLog##level(const wxChar *szFormat,           \
495                                           ...) ATTRIBUTE_PRINTF_1
496 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl)            \
497 extern void expdecl wxVLog##level(argclass arg,                             \
498                                   const wxChar *szFormat,                   \
499                                   va_list argptr);                          \
500 extern void expdecl wxLog##level(argclass arg,                              \
501                                  const wxChar *szFormat,                    \
502                                  ...) ATTRIBUTE_PRINTF_2
503 #else // !wxUSE_LOG
504 
505 // log functions do nothing at all
506 #define DECLARE_LOG_FUNCTION(level)                                         \
507 inline void wxVLog##level(const wxChar *WXUNUSED(szFormat),                 \
508                           va_list WXUNUSED(argptr)) { }                     \
509 inline void wxLog##level(const wxChar *WXUNUSED(szFormat),                  \
510                          ...) { }
511 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl)            \
512 inline void wxVLog##level(argclass WXUNUSED(arg),                           \
513                           const wxChar *WXUNUSED(szFormat),                 \
514                           va_list WXUNUSED(argptr)) {}                      \
515 inline void wxLog##level(argclass WXUNUSED(arg),                            \
516                          const wxChar *WXUNUSED(szFormat),                  \
517                          ...) { }
518 
519 // Empty Class to fake wxLogNull
520 class WXDLLIMPEXP_BASE wxLogNull
521 {
522 public:
wxLogNull()523     wxLogNull() { }
524 };
525 
526 // Dummy macros to replace some functions.
527 #define wxSysErrorCode() (unsigned long)0
528 #define wxSysErrorMsg( X ) (const wxChar*)NULL
529 
530 // Fake symbolic trace masks... for those that are used frequently
531 #define wxTRACE_OleCalls wxEmptyString // OLE interface calls
532 
533 #endif // wxUSE_LOG/!wxUSE_LOG
534 
535 #define DECLARE_LOG_FUNCTION2(level, argclass, arg)                         \
536     DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, WXDLLIMPEXP_BASE)
537 
538 
539 // a generic function for all levels (level is passes as parameter)
540 DECLARE_LOG_FUNCTION2(Generic, wxLogLevel, level);
541 
542 // one function per each level
543 DECLARE_LOG_FUNCTION(FatalError);
544 DECLARE_LOG_FUNCTION(Error);
545 DECLARE_LOG_FUNCTION(Warning);
546 DECLARE_LOG_FUNCTION(Message);
547 DECLARE_LOG_FUNCTION(Info);
548 DECLARE_LOG_FUNCTION(Verbose);
549 
550 // this function sends the log message to the status line of the top level
551 // application frame, if any
552 DECLARE_LOG_FUNCTION(Status);
553 
554 #if wxUSE_GUI
555     // this one is the same as previous except that it allows to explicitly
556     class WXDLLIMPEXP_FWD_CORE wxFrame;
557     // specify the frame to which the output should go
558     DECLARE_LOG_FUNCTION2_EXP(Status, wxFrame *, pFrame, WXDLLIMPEXP_CORE);
559 #endif // wxUSE_GUI
560 
561 // additional one: as wxLogError, but also logs last system call error code
562 // and the corresponding error message if available
563 DECLARE_LOG_FUNCTION(SysError);
564 
565 // and another one which also takes the error code (for those broken APIs
566 // that don't set the errno (like registry APIs in Win32))
567 DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
568 
569 // debug functions do nothing in release mode
570 #if wxUSE_LOG && wxUSE_LOG_DEBUG
571     DECLARE_LOG_FUNCTION(Debug);
572 
573     // there is no more unconditional LogTrace: it is not different from
574     // LogDebug and it creates overload ambiguities
575     //DECLARE_LOG_FUNCTION(Trace);
576 
577     // this version only logs the message if the mask had been added to the
578     // list of masks with AddTraceMask()
579     DECLARE_LOG_FUNCTION2(Trace, const wxChar *, mask);
580 
581     // and this one does nothing if all of level bits are not set in
582     // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
583     // string identifiers
584     DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
585 #else   //!debug || !wxUSE_LOG
586     // these functions do nothing in release builds, but don't define them as
587     // nothing as it could result in different code structure in debug and
588     // release and this could result in trouble when these macros are used
589     // inside if/else
590     //
591     // note that making wxVLogDebug/Trace() themselves (empty inline) functions
592     // is a bad idea as some compilers are stupid enough to not inline even
593     // empty functions if their parameters are complicated enough, but by
594     // defining them as an empty inline function we ensure that even dumbest
595     // compilers optimise them away
wxLogNop()596     inline void wxLogNop() { }
597 
598     #define wxVLogDebug(fmt, valist) wxLogNop()
599     #define wxVLogTrace(mask, fmt, valist) wxLogNop()
600 
601     #ifdef HAVE_VARIADIC_MACROS
602         // unlike the inline functions below, this completely removes the
603         // wxLogXXX calls from the object file:
604         #define wxLogDebug(fmt, ...) wxLogNop()
605         #define wxLogTrace(mask, fmt, ...) wxLogNop()
606     #else // !HAVE_VARIADIC_MACROS
607         // note that leaving out "fmt" in the vararg functions provokes a warning
608         // from SGI CC: "the last argument of the varargs function is unnamed"
wxLogDebug(const wxChar * fmt,...)609         inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); }
wxLogTrace(wxTraceMask,const wxChar * fmt,...)610         inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); }
wxLogTrace(const wxChar *,const wxChar * fmt,...)611         inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); }
612     #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS
613 #endif // debug/!debug
614 
615 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
616 // i.e. without using wxMessageBox() for example because it could crash
617 void WXDLLIMPEXP_BASE
618 wxSafeShowMessage(const wxString& title, const wxString& text);
619 
620 // ----------------------------------------------------------------------------
621 // debug only logging functions: use them with API name and error code
622 // ----------------------------------------------------------------------------
623 
624 #ifdef __WXDEBUG__
625     // make life easier for people using VC++ IDE: clicking on the message
626     // will take us immediately to the place of the failed API
627 #ifdef __VISUALC__
628     #define wxLogApiError(api, rc)                                            \
629         wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."),       \
630                    __TFILE__, __LINE__, api,                                  \
631                    (long)rc, wxSysErrorMsg(rc))
632 #else // !VC++
633     #define wxLogApiError(api, rc)                                            \
634         wxLogDebug(wxT("In file %s at line %d: '%s' failed with ")            \
635                    wxT("error 0x%08lx (%s)."),                                \
636                    __TFILE__, __LINE__, api,                                  \
637                    (long)rc, wxSysErrorMsg(rc))
638 #endif // VC++/!VC++
639 
640     #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
641 
642 #else   //!debug
643     #define wxLogApiError(api, err) wxLogNop()
644     #define wxLogLastError(api) wxLogNop()
645 #endif  //debug/!debug
646 
647 // wxCocoa has additiional trace masks
648 #if defined(__WXCOCOA__)
649 #include "wx/cocoa/log.h"
650 #endif
651 
652 #endif  // _WX_LOG_H_
653 
654