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