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