]> git.saurik.com Git - wxWidgets.git/blame - include/wx/log.h
applied patch 890642: wxRE_ADVANCED flag and docs
[wxWidgets.git] / include / wx / log.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8ca28fb7 2// Name: wx/log.h
c801d85f
KB
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$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
371a5b4e 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
886dd7d2
VZ
12#ifndef _WX_LOG_H_
13#define _WX_LOG_H_
c801d85f 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
d6b9496a 16 #pragma interface "log.h"
0d3820b3 17#endif
c801d85f 18
df5168c4 19#include "wx/defs.h"
38830220 20
546db2a8
VZ
21// ----------------------------------------------------------------------------
22// types
23// ----------------------------------------------------------------------------
24
1782be31 25// NB: these types are needed even if wxUSE_LOG == 0
546db2a8
VZ
26typedef unsigned long wxTraceMask;
27typedef unsigned long wxLogLevel;
28
29// ----------------------------------------------------------------------------
30// headers
31// ----------------------------------------------------------------------------
32
1782be31
VZ
33#if wxUSE_LOG
34
35#include "wx/string.h"
36#include "wx/arrstr.h"
37
0e0126c2 38#ifndef __WXWINCE__
1782be31 39 #include <time.h> // for time_t
0e0126c2 40#endif
c30aaf75
VZ
41
42#include "wx/dynarray.h"
d6b9496a 43
edc73852
RD
44#ifndef wxUSE_LOG_DEBUG
45# ifdef __WXDEBUG__
46# define wxUSE_LOG_DEBUG 1
47# else // !__WXDEBUG__
48# define wxUSE_LOG_DEBUG 0
49# endif
50#endif
51
1782be31
VZ
52// ----------------------------------------------------------------------------
53// forward declarations
54// ----------------------------------------------------------------------------
55
56#if wxUSE_GUI
57 class WXDLLIMPEXP_CORE wxTextCtrl;
58 class WXDLLIMPEXP_CORE wxLogFrame;
59 class WXDLLIMPEXP_CORE wxFrame;
60#endif // wxUSE_GUI
61
9ef3052c
VZ
62// ----------------------------------------------------------------------------
63// constants
64// ----------------------------------------------------------------------------
65
66// different standard log levels (you may also define your own)
67enum
68{
d6b9496a
VZ
69 wxLOG_FatalError, // program can't continue, abort immediately
70 wxLOG_Error, // a serious error, user must be informed about it
71 wxLOG_Warning, // user is normally informed about it but may be ignored
72 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
d6b9496a 73 wxLOG_Status, // informational: might go to the status line of GUI app
edc73852 74 wxLOG_Info, // informational message (a.k.a. 'Verbose')
d6b9496a
VZ
75 wxLOG_Debug, // never shown to the user, disabled in release mode
76 wxLOG_Trace, // trace messages are also only enabled in debug mode
77 wxLOG_Progress, // used for progress indicator (not yet)
edc73852 78 wxLOG_User = 100, // user defined levels start here
65ca8c0b 79 wxLOG_Max = 10000
9ef3052c
VZ
80};
81
d6b9496a
VZ
82// symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
83// discarded unless the string "foo" has been added to the list of allowed
84// ones with AddTraceMask()
85
08298395
OK
86#define wxTRACE_MemAlloc wxT("memalloc") // trace memory allocation (new/delete)
87#define wxTRACE_Messages wxT("messages") // trace window messages/X callbacks
88#define wxTRACE_ResAlloc wxT("resalloc") // trace GDI resource allocation
89#define wxTRACE_RefCount wxT("refcount") // trace various ref counting operations
d6b9496a
VZ
90
91#ifdef __WXMSW__
08298395 92 #define wxTRACE_OleCalls wxT("ole") // OLE interface calls
d6b9496a
VZ
93#endif
94
95// the trace masks have been superceded by symbolic trace constants, they're
96// for compatibility only andwill be removed soon - do NOT use them
97
9ef3052c
VZ
98// meaning of different bits of the trace mask (which allows selectively
99// enable/disable some trace messages)
100#define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete)
101#define wxTraceMessages 0x0002 // trace window messages/X callbacks
102#define wxTraceResAlloc 0x0004 // trace GDI resource allocation
103#define wxTraceRefCount 0x0008 // trace various ref counting operations
104
2049ba38 105#ifdef __WXMSW__
d6b9496a 106 #define wxTraceOleCalls 0x0100 // OLE interface calls
9ef3052c
VZ
107#endif
108
65f19af1 109#include "wx/iosfwrap.h"
470b7da3 110
c801d85f
KB
111// ----------------------------------------------------------------------------
112// derive from this class to redirect (or suppress, or ...) log messages
113// normally, only a single instance of this class exists but it's not enforced
c801d85f 114// ----------------------------------------------------------------------------
d6b9496a 115
bddd7a8d 116class WXDLLIMPEXP_BASE wxLog
c801d85f
KB
117{
118public:
d6b9496a
VZ
119 // ctor
120 wxLog();
121
04662def 122 // Internal buffer.
d1b20379
DS
123
124 // Allow replacement of the fixed size static buffer with
125 // a user allocated one. Pass in NULL to restore the
126 // built in static buffer.
04662def
RL
127 static wxChar *SetLogBuffer( wxChar *buf, size_t size = 0 );
128
d6b9496a 129 // these functions allow to completely disable all log messages
d1b20379
DS
130
131 // is logging disabled now?
d6b9496a 132 static bool IsEnabled() { return ms_doLog; }
d1b20379
DS
133
134 // change the flag state, return the previous one
135 static bool EnableLogging(bool doIt = true)
136 { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; }
d6b9496a
VZ
137
138 // static sink function - see DoLog() for function to overload in the
139 // derived classes
9e3d3318 140 static void OnLog(wxLogLevel level, const wxChar *szString, time_t t)
d6b9496a 141 {
d1b20379
DS
142 if ( IsEnabled() && ms_logLevel >= level )
143 {
d6b9496a
VZ
144 wxLog *pLogger = GetActiveTarget();
145 if ( pLogger )
146 pLogger->DoLog(level, szString, t);
147 }
803bf1c5 148 }
d6b9496a
VZ
149
150 // message buffering
d1b20379
DS
151
152 // flush shows all messages if they're not logged immediately (FILE
153 // and iostream logs don't need it, but wxGuiLog does to avoid showing
154 // 17 modal dialogs one after another)
d6b9496a 155 virtual void Flush();
d6b9496a 156
d1b20379 157 // flush the active target if any
bbfa0322
VZ
158 static void FlushActive()
159 {
2ed3265e
VZ
160 if ( !ms_suspendCount )
161 {
162 wxLog *log = GetActiveTarget();
1ec5cbf3 163 if ( log )
2ed3265e
VZ
164 log->Flush();
165 }
bbfa0322 166 }
1ec5cbf3
VZ
167
168 // only one sink is active at each moment
d1b20379
DS
169 // get current log target, will call wxApp::CreateLogTarget() to
170 // create one if none exists
d6b9496a 171 static wxLog *GetActiveTarget();
d1b20379
DS
172
173 // change log target, pLogger may be NULL
d6b9496a
VZ
174 static wxLog *SetActiveTarget(wxLog *pLogger);
175
d1b20379
DS
176 // suspend the message flushing of the main target until the next call
177 // to Resume() - this is mainly for internal use (to prevent wxYield()
178 // from flashing the messages)
2ed3265e 179 static void Suspend() { ms_suspendCount++; }
d1b20379
DS
180
181 // must be called for each Suspend()!
2ed3265e
VZ
182 static void Resume() { ms_suspendCount--; }
183
d6b9496a 184 // functions controlling the default wxLog behaviour
d1b20379
DS
185 // verbose mode is activated by standard command-line '-verbose'
186 // option
187 static void SetVerbose(bool bVerbose = true) { ms_bVerbose = bVerbose; }
edc73852 188
d1b20379 189 // Set log level. Log messages with level > logLevel will not be logged.
edc73852
RD
190 static void SetLogLevel(wxLogLevel logLevel) { ms_logLevel = logLevel; }
191
d1b20379
DS
192 // should GetActiveTarget() try to create a new log object if the
193 // current is NULL?
36bd6902 194 static void DontCreateOnDemand();
d6b9496a 195
d1b20379 196 // trace mask (see wxTraceXXX constants for details)
d6b9496a 197 static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
d1b20379
DS
198
199 // add string trace mask
df5168c4 200 static void AddTraceMask(const wxString& str)
d1b20379
DS
201 { ms_aTraceMasks.push_back(str); }
202
203 // add string trace mask
d6b9496a 204 static void RemoveTraceMask(const wxString& str);
d1b20379
DS
205
206 // remove all string trace masks
36bd6902 207 static void ClearTraceMasks();
d1b20379
DS
208
209 // get string trace masks
0e080be6 210 static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; }
d6b9496a 211
d1b20379
DS
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.
d2e1ef19
VZ
215 static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; }
216
edc73852 217
d6b9496a 218 // accessors
d1b20379
DS
219
220 // gets the verbose status
fd7718b2 221 static bool GetVerbose() { return ms_bVerbose; }
d1b20379
DS
222
223 // get trace mask
d6b9496a 224 static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
d1b20379
DS
225
226 // is this trace mask in the list?
df5168c4 227 static bool IsAllowedTraceMask(const wxChar *mask);
d1b20379
DS
228
229 // return the current loglevel limit
edc73852 230 static wxLogLevel GetLogLevel() { return ms_logLevel; }
d6b9496a 231
d1b20379 232 // get the current timestamp format string (may be NULL)
d2e1ef19
VZ
233 static const wxChar *GetTimestamp() { return ms_timestamp; }
234
edc73852 235
d2e1ef19 236 // helpers
d1b20379
DS
237
238 // put the time stamp into the string if ms_timestamp != NULL (don't
239 // change it otherwise)
d2e1ef19
VZ
240 static void TimeStamp(wxString *str);
241
d6b9496a
VZ
242 // make dtor virtual for all derived classes
243 virtual ~wxLog() { }
c801d85f 244
c801d85f 245
1ec5cbf3 246 // this method exists for backwards compatibility only, don't use
d1b20379 247 bool HasPendingMessages() const { return true; }
1ec5cbf3
VZ
248
249protected:
d6b9496a 250 // the logging functions that can be overriden
d1b20379
DS
251
252 // default DoLog() prepends the time stamp and a prefix corresponding
253 // to the message to szString and then passes it to DoLogString()
9e3d3318 254 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
d1b20379
DS
255
256 // default DoLogString does nothing but is not pure virtual because if
257 // you override DoLog() you might not need it at all
9e3d3318 258 virtual void DoLogString(const wxChar *szString, time_t t);
c801d85f 259
d6b9496a
VZ
260private:
261 // static variables
262 // ----------------
06db8ebd 263
d6b9496a 264 static wxLog *ms_pLogger; // currently active log sink
d1b20379 265 static bool ms_doLog; // false => all logging disabled
d6b9496a 266 static bool ms_bAutoCreate; // create new log targets on demand?
d1b20379 267 static bool ms_bVerbose; // false => ignore LogInfo messages
fe7b1156 268
edc73852
RD
269 static wxLogLevel ms_logLevel; // limit logging to levels <= ms_logLevel
270
2ed3265e
VZ
271 static size_t ms_suspendCount; // if positive, logs are not flushed
272
d2e1ef19
VZ
273 // format string for strftime(), if NULL, time stamping log messages is
274 // disabled
275 static const wxChar *ms_timestamp;
276
d6b9496a
VZ
277 static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
278 static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
c801d85f
KB
279};
280
281// ----------------------------------------------------------------------------
282// "trivial" derivations of wxLog
283// ----------------------------------------------------------------------------
284
285// log everything to a "FILE *", stderr by default
bddd7a8d 286class WXDLLIMPEXP_BASE wxLogStderr : public wxLog
c801d85f 287{
be52b341 288 DECLARE_NO_COPY_CLASS(wxLogStderr)
64bea2bf 289
c801d85f 290public:
d6b9496a
VZ
291 // redirect log output to a FILE
292 wxLogStderr(FILE *fp = (FILE *) NULL);
c801d85f 293
03147cd0 294protected:
d6b9496a 295 // implement sink function
9e3d3318 296 virtual void DoLogString(const wxChar *szString, time_t t);
c801d85f 297
d6b9496a 298 FILE *m_fp;
c801d85f
KB
299};
300
4bf78aae 301#if wxUSE_STD_IOSTREAM
03147cd0 302
c801d85f 303// log everything to an "ostream", cerr by default
bddd7a8d 304class WXDLLIMPEXP_BASE wxLogStream : public wxLog
c801d85f
KB
305{
306public:
d6b9496a 307 // redirect log output to an ostream
dd107c50 308 wxLogStream(wxSTD ostream *ostr = (wxSTD ostream *) NULL);
c801d85f
KB
309
310protected:
d6b9496a 311 // implement sink function
9e3d3318 312 virtual void DoLogString(const wxChar *szString, time_t t);
c801d85f 313
d6b9496a 314 // using ptr here to avoid including <iostream.h> from this file
dd107c50 315 wxSTD ostream *m_ostr;
c801d85f 316};
03147cd0
VZ
317
318#endif // wxUSE_STD_IOSTREAM
c801d85f 319
03147cd0
VZ
320// ----------------------------------------------------------------------------
321// /dev/null log target: suppress logging until this object goes out of scope
322// ----------------------------------------------------------------------------
323
324// example of usage:
325/*
326 void Foo()
327 {
328 wxFile file;
329
330 // wxFile.Open() normally complains if file can't be opened, we don't
331 // want it
332 wxLogNull logNo;
333
334 if ( !file.Open("bar") )
335 ... process error ourselves ...
336
337 // ~wxLogNull called, old log sink restored
338 }
339 */
bddd7a8d 340class WXDLLIMPEXP_BASE wxLogNull
03147cd0
VZ
341{
342public:
d1b20379 343 wxLogNull() : m_flagOld(wxLog::EnableLogging(false)) { }
be52b341 344 ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
03147cd0
VZ
345
346private:
347 bool m_flagOld; // the previous value of the wxLog::ms_doLog
348};
349
350// ----------------------------------------------------------------------------
351// chaining log target: installs itself as a log target and passes all
352// messages to the real log target given to it in the ctor but also forwards
353// them to the previously active one
354//
355// note that you don't have to call SetActiveTarget() with this class, it
356// does it itself in its ctor
357// ----------------------------------------------------------------------------
358
bddd7a8d 359class WXDLLIMPEXP_BASE wxLogChain : public wxLog
03147cd0
VZ
360{
361public:
362 wxLogChain(wxLog *logger);
8b30a4e4 363 virtual ~wxLogChain();
03147cd0
VZ
364
365 // change the new log target
366 void SetLog(wxLog *logger);
367
368 // this can be used to temporarily disable (and then reenable) passing
369 // messages to the old logger (by default we do pass them)
370 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
371
372 // are we passing the messages to the previous log target?
373 bool IsPassingMessages() const { return m_bPassMessages; }
374
375 // return the previous log target (may be NULL)
376 wxLog *GetOldLog() const { return m_logOld; }
377
378 // override base class version to flush the old logger as well
379 virtual void Flush();
380
381protected:
382 // pass the chain to the old logger if needed
383 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
384
385private:
386 // the current log target
387 wxLog *m_logNew;
388
389 // the previous log target
390 wxLog *m_logOld;
391
392 // do we pass the messages to the old logger?
393 bool m_bPassMessages;
22f3361e
VZ
394
395 DECLARE_NO_COPY_CLASS(wxLogChain)
03147cd0
VZ
396};
397
398// a chain log target which uses itself as the new logger
bddd7a8d 399class WXDLLIMPEXP_BASE wxLogPassThrough : public wxLogChain
03147cd0
VZ
400{
401public:
93d4c1d0 402 wxLogPassThrough();
fc7a2a60
VZ
403
404private:
405 DECLARE_NO_COPY_CLASS(wxLogPassThrough)
03147cd0
VZ
406};
407
8ca28fb7 408#if wxUSE_GUI
7e8c564c
VS
409 // include GUI log targets:
410 #include "wx/generic/logg.h"
e90c1d2a 411#endif // wxUSE_GUI
03f38c58 412
c801d85f
KB
413// ============================================================================
414// global functions
415// ============================================================================
416
417// ----------------------------------------------------------------------------
418// Log functions should be used by application instead of stdio, iostream &c
419// for log messages for easy redirection
420// ----------------------------------------------------------------------------
421
88ac883a
VZ
422// ----------------------------------------------------------------------------
423// get error code/error message from system in a portable way
424// ----------------------------------------------------------------------------
425
426// return the last system error code
bddd7a8d 427WXDLLIMPEXP_BASE unsigned long wxSysErrorCode();
c11d62a6 428
88ac883a 429// return the error message for given (or last if 0) error code
bddd7a8d 430WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
88ac883a 431
c11d62a6 432// ----------------------------------------------------------------------------
c801d85f 433// define wxLog<level>
c11d62a6 434// ----------------------------------------------------------------------------
c801d85f 435
886dd7d2 436#define DECLARE_LOG_FUNCTION(level) \
bddd7a8d 437extern void WXDLLIMPEXP_BASE wxVLog##level(const wxChar *szFormat, \
886dd7d2 438 va_list argptr); \
bddd7a8d 439extern void WXDLLIMPEXP_BASE wxLog##level(const wxChar *szFormat, \
7357f981 440 ...) ATTRIBUTE_PRINTF_1
886dd7d2
VZ
441#define DECLARE_LOG_FUNCTION2_EXP(level, arg, expdecl) \
442extern void expdecl wxVLog##level(arg, const wxChar *szFormat, \
443 va_list argptr); \
444extern void expdecl wxLog##level(arg, const wxChar *szFormat, \
7357f981 445 ...) ATTRIBUTE_PRINTF_2
886dd7d2 446#define DECLARE_LOG_FUNCTION2(level, arg) \
bddd7a8d 447 DECLARE_LOG_FUNCTION2_EXP(level, arg, WXDLLIMPEXP_BASE)
a1530845 448
88ac883a
VZ
449#else // !wxUSE_LOG
450
451// log functions do nothing at all
886dd7d2
VZ
452#define DECLARE_LOG_FUNCTION(level) \
453inline void wxVLog##level(const wxChar *szFormat, \
454 va_list argptr) { } \
455inline void wxLog##level(const wxChar *szFormat, ...) { }
456#define DECLARE_LOG_FUNCTION2(level, arg) \
457inline void wxVLog##level(arg, const wxChar *szFormat, \
458 va_list argptr) {} \
459inline void wxLog##level(arg, const wxChar *szFormat, ...) { }
88ac883a 460
e30285ab 461// Empty Class to fake wxLogNull
bddd7a8d 462class WXDLLIMPEXP_BASE wxLogNull
e30285ab
VZ
463{
464public:
886dd7d2 465 wxLogNull() { }
e30285ab
VZ
466};
467
468// Dummy macros to replace some functions.
469#define wxSysErrorCode() (unsigned long)0
470#define wxSysErrorMsg( X ) (const wxChar*)NULL
471
472// Fake symbolic trace masks... for those that are used frequently
fda7962d 473#define wxTRACE_OleCalls wxEmptyString // OLE interface calls
e30285ab 474
88ac883a 475#endif // wxUSE_LOG/!wxUSE_LOG
c801d85f 476
88ac883a
VZ
477// a generic function for all levels (level is passes as parameter)
478DECLARE_LOG_FUNCTION2(Generic, wxLogLevel level);
c801d85f 479
88ac883a
VZ
480// one function per each level
481DECLARE_LOG_FUNCTION(FatalError);
482DECLARE_LOG_FUNCTION(Error);
483DECLARE_LOG_FUNCTION(Warning);
484DECLARE_LOG_FUNCTION(Message);
485DECLARE_LOG_FUNCTION(Info);
486DECLARE_LOG_FUNCTION(Verbose);
470b7da3 487
88ac883a
VZ
488// this function sends the log message to the status line of the top level
489// application frame, if any
490DECLARE_LOG_FUNCTION(Status);
470b7da3 491
886dd7d2
VZ
492#if wxUSE_GUI
493 // this one is the same as previous except that it allows to explicitly
494 // specify the frame to which the output should go
bddd7a8d 495 DECLARE_LOG_FUNCTION2_EXP(Status, wxFrame *pFrame, WXDLLIMPEXP_CORE);
886dd7d2 496#endif // wxUSE_GUI
c801d85f 497
88ac883a
VZ
498// additional one: as wxLogError, but also logs last system call error code
499// and the corresponding error message if available
500DECLARE_LOG_FUNCTION(SysError);
c801d85f 501
88ac883a
VZ
502// and another one which also takes the error code (for those broken APIs
503// that don't set the errno (like registry APIs in Win32))
504DECLARE_LOG_FUNCTION2(SysError, long lErrCode);
505
506// debug functions do nothing in release mode
edc73852 507#if wxUSE_LOG_DEBUG
d6b9496a
VZ
508 DECLARE_LOG_FUNCTION(Debug);
509
b103e4f3
VZ
510 // there is no more unconditional LogTrace: it is not different from
511 // LogDebug and it creates overload ambiguities
512 //DECLARE_LOG_FUNCTION(Trace);
d6b9496a 513
b103e4f3
VZ
514 // this version only logs the message if the mask had been added to the
515 // list of masks with AddTraceMask()
f6bcfd97 516 DECLARE_LOG_FUNCTION2(Trace, const wxChar *mask);
9ef3052c 517
b103e4f3
VZ
518 // and this one does nothing if all of level bits are not set in
519 // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
d6b9496a
VZ
520 // string identifiers
521 DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
9ef3052c 522#else //!debug
d6b9496a 523 // these functions do nothing in release builds
1d63fd6b 524 inline void wxVLogDebug(const wxChar *, va_list) { }
9e3d3318 525 inline void wxLogDebug(const wxChar *, ...) { }
1d63fd6b 526 inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { }
9e3d3318 527 inline void wxLogTrace(wxTraceMask, const wxChar *, ...) { }
1d63fd6b 528 inline void wxVLogTrace(const wxChar *, const wxChar *, va_list) { }
9e3d3318 529 inline void wxLogTrace(const wxChar *, const wxChar *, ...) { }
88ac883a 530#endif // debug/!debug
c801d85f 531
c11d62a6
VZ
532// wxLogFatalError helper: show the (fatal) error to the user in a safe way,
533// i.e. without using wxMessageBox() for example because it could crash
bddd7a8d 534void WXDLLIMPEXP_BASE
886dd7d2 535wxSafeShowMessage(const wxString& title, const wxString& text);
c11d62a6 536
88ac883a
VZ
537// ----------------------------------------------------------------------------
538// debug only logging functions: use them with API name and error code
539// ----------------------------------------------------------------------------
c801d85f 540
e90babdf 541#ifdef __WXDEBUG__
42e69d6b
VZ
542 // make life easier for people using VC++ IDE: clicking on the message
543 // will take us immediately to the place of the failed API
544#ifdef __VISUALC__
4b7f2165
VZ
545 #define wxLogApiError(api, rc) \
546 wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."), \
8b94d999
VZ
547 __TFILE__, __LINE__, api, \
548 (long)rc, wxSysErrorMsg(rc))
42e69d6b 549#else // !VC++
4b7f2165 550 #define wxLogApiError(api, rc) \
18da7cf2
VZ
551 wxLogDebug(wxT("In file %s at line %d: '%s' failed with ") \
552 wxT("error 0x%08lx (%s)."), \
8b94d999
VZ
553 __TFILE__, __LINE__, api, \
554 (long)rc, wxSysErrorMsg(rc))
42e69d6b
VZ
555#endif // VC++/!VC++
556
557 #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
558
c801d85f 559#else //!debug
594ed110
DS
560 inline void wxLogApiError(const wxChar *, long) { }
561 inline void wxLogLastError(const wxChar *) { }
c801d85f
KB
562#endif //debug/!debug
563
a619fa3f
DE
564// wxCocoa has additiional trace masks
565#if defined(__WXCOCOA__)
566#include "wx/cocoa/log.h"
567#endif
568
34138703 569#endif // _WX_LOG_H_
04662def 570