]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/log.h
More compilation fixes after wxNOEXCEPT introduction.
[wxWidgets.git] / interface / wx / log.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: log.h
54e280d8 3// Purpose: interface of wxLog* classes
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
83e056ab 9#if wxUSE_BASE
4a6665c6
FM
10
11/**
12 Different standard log levels (you may also define your own) used with
75e488d5 13 by standard wxLog functions wxLogGeneric(), wxLogError(), wxLogWarning(), etc...
4a6665c6
FM
14*/
15enum wxLogLevelValues
16{
17 wxLOG_FatalError, //!< program can't continue, abort immediately
18 wxLOG_Error, //!< a serious error, user must be informed about it
19 wxLOG_Warning, //!< user is normally informed about it but may be ignored
20 wxLOG_Message, //!< normal message (i.e. normal output of a non GUI app)
21 wxLOG_Status, //!< informational: might go to the status line of GUI app
22 wxLOG_Info, //!< informational message (a.k.a. 'Verbose')
23 wxLOG_Debug, //!< never shown to the user, disabled in release mode
24 wxLOG_Trace, //!< trace messages are also only enabled in debug mode
25 wxLOG_Progress, //!< used for progress indicator (not yet)
26 wxLOG_User = 100, //!< user defined levels start here
27 wxLOG_Max = 10000
28};
29
4a6665c6
FM
30/**
31 The type used to specify a log level.
32
33 Default values of ::wxLogLevel used by wxWidgets are contained in the
34 ::wxLogLevelValues enumeration.
35*/
36typedef unsigned long wxLogLevel;
37
bc73d5ae
VZ
38/**
39 Information about a log record (unit of the log output).
40 */
af588446 41class wxLogRecordInfo
bc73d5ae 42{
af588446
VZ
43public:
44 /// The name of the file where this log message was generated.
45 const char *filename;
46
47 /// The line number at which this log message was generated.
48 int line;
49
50 /**
51 The name of the function where the log record was generated.
52
53 This field may be @NULL if the compiler doesn't support @c __FUNCTION__
54 (but most modern compilers do).
55 */
56 const char *func;
57
bc73d5ae
VZ
58 /// Time when the log message was generated.
59 time_t timestamp;
60
61 /**
62 Id of the thread in which the message was generated.
63
64 This field is only available if wxWidgets was built with threads
65 support (<code>wxUSE_THREADS == 1</code>).
66
67 @see wxThread::GetCurrentId()
68 */
69 wxThreadIdType threadId;
70};
4a6665c6 71
432bd6b1 72/**
83e056ab 73 @class wxLogFormatter
432bd6b1 74
83e056ab
VZ
75 wxLogFormatter class is used to format the log messages. It implements the
76 default formatting and can be derived from to create custom formatters.
432bd6b1 77
83e056ab
VZ
78 The default implementation formats the message into a string containing
79 the time stamp, level-dependent prefix and the message itself.
80
81 To change it, you can derive from it and override its Format() method. For
82 example, to include the thread id in the log messages you can use
83 @code
84 class LogFormatterWithThread : public wxLogFormatter
85 {
86 virtual wxString Format(wxLogLevel level,
87 const wxString& msg,
88 const wxLogRecordInfo& info) const
89 {
90 return wxString::Format("[%d] %s(%d) : %s",
91 info.threadId, info.filename, info.line, msg);
92 }
93 };
94 @endcode
95 And then associate it with wxLog instance using its SetFormatter(). Then,
96 if you call:
97
98 @code
99 wxLogMessage(_("*** Application started ***"));
100 @endcode
101
102 the log output could be something like:
103
104 @verbatim
105 [7872] d:\testApp\src\testApp.cpp(85) : *** Application started ***
106 @endverbatim
107
108 @library{wxbase}
432bd6b1
VZ
109 @category{logging}
110
83e056ab
VZ
111 @see @ref overview_log
112
113 @since 2.9.4
432bd6b1 114*/
83e056ab 115class wxLogFormatter
432bd6b1
VZ
116{
117public:
118 /**
83e056ab 119 The default ctor does nothing.
432bd6b1 120 */
83e056ab 121 wxLogFormatter();
432bd6b1 122
432bd6b1
VZ
123
124 /**
83e056ab 125 This function creates the full log message string.
432bd6b1 126
83e056ab 127 Override it to customize the output string format.
432bd6b1 128
83e056ab
VZ
129 @param level
130 The level of this log record, e.g. ::wxLOG_Error.
131 @param msg
132 The log message itself.
133 @param info
134 All the other information (such as time, component, location...)
135 associated with this log record.
432bd6b1 136
83e056ab
VZ
137 @return
138 The formated message.
432bd6b1 139
83e056ab
VZ
140 @note
141 Time stamping is disabled for Visual C++ users in debug builds by
142 default because otherwise it would be impossible to directly go to the line
143 from which the log message was generated by simply clicking in the debugger
144 window on the corresponding error message. If you wish to enable it, override
145 FormatTime().
432bd6b1 146 */
83e056ab
VZ
147 virtual wxString Format(wxLogLevel level,
148 const wxString& msg,
149 const wxLogRecordInfo& info) const;
432bd6b1 150
83e056ab 151protected:
432bd6b1 152 /**
83e056ab 153 This function formats the time stamp part of the log message.
432bd6b1 154
83e056ab 155 Override this function if you need to customize just the time stamp.
432bd6b1 156
83e056ab
VZ
157 @param time
158 Time to format.
432bd6b1 159
83e056ab
VZ
160 @return
161 The formated time string, may be empty.
432bd6b1 162 */
83e056ab 163 virtual wxString FormatTime(time_t time) const;
432bd6b1
VZ
164};
165
166
432bd6b1 167/**
83e056ab 168 @class wxLog
432bd6b1 169
83e056ab
VZ
170 wxLog class defines the interface for the <em>log targets</em> used by wxWidgets
171 logging functions as explained in the @ref overview_log.
432bd6b1 172
83e056ab
VZ
173 The only situations when you need to directly use this class is when you want
174 to derive your own log target because the existing ones don't satisfy your
175 needs.
432bd6b1 176
83e056ab
VZ
177 Otherwise, it is completely hidden behind the @ref group_funcmacro_log "wxLogXXX() functions"
178 and you may not even know about its existence.
432bd6b1 179
83e056ab
VZ
180 @note For console-mode applications, the default target is wxLogStderr, so
181 that all @e wxLogXXX() functions print on @c stderr when @c wxUSE_GUI = 0.
432bd6b1
VZ
182
183 @library{wxbase}
184 @category{logging}
83e056ab
VZ
185
186 @see @ref overview_log, @ref group_funcmacro_log "wxLogXXX() functions"
432bd6b1 187*/
83e056ab 188class wxLog
432bd6b1
VZ
189{
190public:
191 /**
83e056ab 192 @name Trace mask functions
432bd6b1 193 */
83e056ab 194 //@{
432bd6b1
VZ
195
196 /**
83e056ab 197 Add the @a mask to the list of allowed masks for wxLogTrace().
432bd6b1 198
83e056ab 199 @see RemoveTraceMask(), GetTraceMasks()
432bd6b1 200 */
83e056ab 201 static void AddTraceMask(const wxString& mask);
432bd6b1
VZ
202
203 /**
83e056ab
VZ
204 Removes all trace masks previously set with AddTraceMask().
205
206 @see RemoveTraceMask()
432bd6b1 207 */
83e056ab 208 static void ClearTraceMasks();
432bd6b1
VZ
209
210 /**
83e056ab
VZ
211 Returns the currently allowed list of string trace masks.
212
213 @see AddTraceMask().
432bd6b1 214 */
83e056ab 215 static const wxArrayString& GetTraceMasks();
432bd6b1
VZ
216
217 /**
83e056ab
VZ
218 Returns @true if the @a mask is one of allowed masks for wxLogTrace().
219
220 See also: AddTraceMask(), RemoveTraceMask()
432bd6b1 221 */
83e056ab 222 static bool IsAllowedTraceMask(const wxString& mask);
432bd6b1
VZ
223
224 /**
83e056ab
VZ
225 Remove the @a mask from the list of allowed masks for
226 wxLogTrace().
432bd6b1 227
83e056ab 228 @see AddTraceMask()
432bd6b1 229 */
83e056ab 230 static void RemoveTraceMask(const wxString& mask);
432bd6b1 231
83e056ab 232 //@}
432bd6b1 233
432bd6b1 234
432bd6b1 235
83e056ab
VZ
236 /**
237 @name Log target functions
238 */
239 //@{
432bd6b1 240
83e056ab
VZ
241 /**
242 Instructs wxLog to not create new log targets on the fly if there is none
243 currently (see GetActiveTarget()).
432bd6b1 244
83e056ab
VZ
245 (Almost) for internal use only: it is supposed to be called by the
246 application shutdown code (where you don't want the log target to be
247 automatically created anymore).
432bd6b1 248
83e056ab
VZ
249 Note that this function also calls ClearTraceMasks().
250 */
251 static void DontCreateOnDemand();
432bd6b1 252
432bd6b1 253 /**
83e056ab
VZ
254 Returns the pointer to the active log target (may be @NULL).
255
256 Notice that if SetActiveTarget() hadn't been previously explicitly
257 called, this function will by default try to create a log target by
258 calling wxAppTraits::CreateLogTarget() which may be overridden in a
259 user-defined traits class to change the default behaviour. You may also
260 call DontCreateOnDemand() to disable this behaviour.
261
262 When this function is called from threads other than main one,
263 auto-creation doesn't happen. But if the thread has a thread-specific
264 log target previously set by SetThreadActiveTarget(), it is returned
265 instead of the global one. Otherwise, the global log target is
266 returned.
432bd6b1 267 */
83e056ab 268 static wxLog* GetActiveTarget();
432bd6b1
VZ
269
270 /**
83e056ab 271 Sets the specified log target as the active one.
432bd6b1 272
83e056ab
VZ
273 Returns the pointer to the previous active log target (may be @NULL).
274 To suppress logging use a new instance of wxLogNull not @NULL. If the
275 active log target is set to @NULL a new default log target will be
276 created when logging occurs.
277
278 @see SetThreadActiveTarget()
279 */
280 static wxLog* SetActiveTarget(wxLog* logtarget);
432bd6b1 281
432bd6b1 282 /**
83e056ab 283 Sets a thread-specific log target.
432bd6b1 284
83e056ab
VZ
285 The log target passed to this function will be used for all messages
286 logged by the current thread using the usual wxLog functions. This
287 shouldn't be called from the main thread which never uses a thread-
288 specific log target but can be used for the other threads to handle
289 thread logging completely separately; instead of buffering thread log
290 messages in the main thread logger.
432bd6b1 291
83e056ab
VZ
292 Notice that unlike for SetActiveTarget(), wxWidgets does not destroy
293 the thread-specific log targets when the thread terminates so doing
294 this is your responsibility.
432bd6b1 295
83e056ab
VZ
296 This method is only available if @c wxUSE_THREADS is 1, i.e. wxWidgets
297 was compiled with threads support.
298
299 @param logger
300 The new thread-specific log target, possibly @NULL.
301 @return
302 The previous thread-specific log target, initially @NULL.
303
304 @since 2.9.1
432bd6b1 305 */
83e056ab 306 static wxLog *SetThreadActiveTarget(wxLog *logger);
432bd6b1
VZ
307
308 /**
83e056ab 309 Flushes the current log target if any, does nothing if there is none.
432bd6b1 310
83e056ab
VZ
311 When this method is called from the main thread context, it also
312 flushes any previously buffered messages logged by the other threads.
313 When it is called from the other threads it simply calls Flush() on the
314 currently active log target, so it mostly makes sense to do this if a
315 thread has its own logger set with SetThreadActiveTarget().
316 */
317 static void FlushActive();
432bd6b1 318
83e056ab
VZ
319 /**
320 Resumes logging previously suspended by a call to Suspend().
321 All messages logged in the meanwhile will be flushed soon.
322 */
323 static void Resume();
432bd6b1
VZ
324
325 /**
83e056ab 326 Suspends the logging until Resume() is called.
432bd6b1 327
83e056ab
VZ
328 Note that the latter must be called the same number of times as the former
329 to undo it, i.e. if you call Suspend() twice you must call Resume() twice as well.
432bd6b1 330
83e056ab
VZ
331 Note that suspending the logging means that the log sink won't be flushed
332 periodically, it doesn't have any effect if the current log target does the
333 logging immediately without waiting for Flush() to be called (the standard
334 GUI log target only shows the log dialog when it is flushed, so Suspend()
335 works as expected with it).
432bd6b1 336
83e056ab
VZ
337 @see Resume(), wxLogNull
338 */
339 static void Suspend();
432bd6b1 340
83e056ab 341 //@}
432bd6b1 342
432bd6b1 343
432bd6b1
VZ
344
345 /**
83e056ab
VZ
346 @name Log level functions
347 */
348 //@{
432bd6b1
VZ
349
350 /**
83e056ab 351 Returns the current log level limit.
432bd6b1 352
83e056ab
VZ
353 All messages at levels strictly greater than the value returned by this
354 function are not logged at all.
432bd6b1 355
83e056ab
VZ
356 @see SetLogLevel(), IsLevelEnabled()
357 */
358 static wxLogLevel GetLogLevel();
432bd6b1 359
432bd6b1 360 /**
83e056ab 361 Returns true if logging at this level is enabled for the current thread.
432bd6b1 362
83e056ab
VZ
363 This function only returns @true if logging is globally enabled and if
364 @a level is less than or equal to the maximal log level enabled for the
365 given @a component.
432bd6b1 366
83e056ab
VZ
367 @see IsEnabled(), SetLogLevel(), GetLogLevel(), SetComponentLevel()
368
369 @since 2.9.1
432bd6b1 370 */
83e056ab 371 static bool IsLevelEnabled(wxLogLevel level, wxString component);
432bd6b1
VZ
372
373 /**
83e056ab 374 Sets the log level for the given component.
432bd6b1 375
83e056ab
VZ
376 For example, to disable all but error messages from wxWidgets network
377 classes you may use
378 @code
379 wxLog::SetComponentLevel("wx/net", wxLOG_Error);
380 @endcode
432bd6b1 381
83e056ab 382 SetLogLevel() may be used to set the global log level.
432bd6b1 383
83e056ab
VZ
384 @param component
385 Non-empty component name, possibly using slashes (@c /) to separate
386 it into several parts.
387 @param level
388 Maximal level of log messages from this component which will be
389 handled instead of being simply discarded.
432bd6b1 390
83e056ab
VZ
391 @since 2.9.1
392 */
393 static void SetComponentLevel(const wxString& component, wxLogLevel level);
432bd6b1 394
83e056ab
VZ
395 /**
396 Specifies that log messages with level greater (numerically) than
397 @a logLevel should be ignored and not sent to the active log target.
432bd6b1 398
83e056ab
VZ
399 @see SetComponentLevel()
400 */
401 static void SetLogLevel(wxLogLevel logLevel);
402
403 //@}
432bd6b1 404
432bd6b1 405
432bd6b1 406
432bd6b1 407 /**
83e056ab 408 @name Enable/disable features functions
432bd6b1 409 */
83e056ab 410 //@{
432bd6b1 411
83e056ab
VZ
412 /**
413 Globally enable or disable logging.
432bd6b1 414
83e056ab
VZ
415 Calling this function with @false argument disables all log messages
416 for the current thread.
432bd6b1 417
83e056ab 418 @see wxLogNull, IsEnabled()
432bd6b1 419
83e056ab
VZ
420 @return
421 The old state, i.e. @true if logging was previously enabled and
422 @false if it was disabled.
423 */
424 static bool EnableLogging(bool enable = true);
432bd6b1 425
83e056ab
VZ
426 /**
427 Returns true if logging is enabled at all now.
432bd6b1 428
83e056ab
VZ
429 @see IsLevelEnabled(), EnableLogging()
430 */
431 static bool IsEnabled();
432bd6b1 432
432bd6b1 433 /**
83e056ab 434 Returns whether the repetition counting mode is enabled.
432bd6b1 435 */
83e056ab 436 static bool GetRepetitionCounting();
432bd6b1 437
83e056ab
VZ
438 /**
439 Enables logging mode in which a log message is logged once, and in case exactly
440 the same message successively repeats one or more times, only the number of
441 repetitions is logged.
442 */
443 static void SetRepetitionCounting(bool repetCounting = true);
432bd6b1 444
83e056ab
VZ
445 /**
446 Returns the current timestamp format string.
432bd6b1 447
83e056ab
VZ
448 Notice that the current time stamp is only used by the default log
449 formatter and custom formatters may ignore this format.
450 */
451 static const wxString& GetTimestamp();
432bd6b1 452
83e056ab
VZ
453 /**
454 Sets the timestamp format prepended by the default log targets to all
455 messages. The string may contain any normal characters as well as %
456 prefixed format specifiers, see @e strftime() manual for details.
457 Passing an empty string to this function disables message time stamping.
432bd6b1 458
83e056ab
VZ
459 Notice that the current time stamp is only used by the default log
460 formatter and custom formatters may ignore this format. You can also
461 define a custom wxLogFormatter to customize the time stamp handling
462 beyond changing its format.
463 */
464 static void SetTimestamp(const wxString& format);
432bd6b1 465
432bd6b1 466 /**
83e056ab
VZ
467 Disables time stamping of the log messages.
468
469 Notice that the current time stamp is only used by the default log
470 formatter and custom formatters may ignore calls to this function.
471
472 @since 2.9.0
432bd6b1 473 */
83e056ab 474 static void DisableTimestamp();
432bd6b1
VZ
475
476 /**
83e056ab 477 Returns whether the verbose mode is currently active.
432bd6b1 478 */
83e056ab 479 static bool GetVerbose();
432bd6b1
VZ
480
481 /**
83e056ab
VZ
482 Activates or deactivates verbose mode in which the verbose messages are
483 logged as the normal ones instead of being silently dropped.
484
485 The verbose messages are the trace messages which are not disabled in the
486 release mode and are generated by wxLogVerbose().
487
488 @see @ref overview_log
432bd6b1 489 */
83e056ab 490 static void SetVerbose(bool verbose = true);
432bd6b1 491
83e056ab 492 //@}
432bd6b1
VZ
493
494
83e056ab
VZ
495 /**
496 Sets the specified formatter as the active one.
432bd6b1 497
83e056ab
VZ
498 @param formatter
499 The new formatter. If @NULL, reset to the default formatter.
432bd6b1 500
83e056ab
VZ
501 Returns the pointer to the previous formatter. You must delete it
502 if you don't plan to attach it again to a wxLog object later.
503
504 @since 2.9.4
505 */
506 wxLogFormatter *SetFormatter(wxLogFormatter* formatter);
432bd6b1 507
432bd6b1 508
432bd6b1 509 /**
83e056ab
VZ
510 Some of wxLog implementations, most notably the standard wxLogGui class,
511 buffer the messages (for example, to avoid showing the user a zillion of modal
512 message boxes one after another -- which would be really annoying).
513 This function shows them all and clears the buffer contents.
514 If the buffer is already empty, nothing happens.
515
516 If you override this method in a derived class, call the base class
517 version first, before doing anything else.
432bd6b1 518 */
83e056ab 519 virtual void Flush();
432bd6b1 520
83e056ab
VZ
521 /**
522 Log the given record.
432bd6b1 523
83e056ab
VZ
524 This function should only be called from the DoLog() implementations in
525 the derived classes if they need to call DoLogRecord() on another log
526 object (they can, of course, just use wxLog::DoLogRecord() call syntax
527 to call it on the object itself). It should not be used for logging new
528 messages which can be only sent to the currently active logger using
529 OnLog() which also checks if the logging (for this level) is enabled
530 while this method just directly calls DoLog().
432bd6b1 531
83e056ab
VZ
532 Example of use of this class from wxLogChain:
533 @code
534 void wxLogChain::DoLogRecord(wxLogLevel level,
535 const wxString& msg,
536 const wxLogRecordInfo& info)
537 {
538 // let the previous logger show it
539 if ( m_logOld && IsPassingMessages() )
540 m_logOld->LogRecord(level, msg, info);
432bd6b1 541
83e056ab
VZ
542 // and also send it to the new one
543 if ( m_logNew && m_logNew != this )
544 m_logNew->LogRecord(level, msg, info);
545 }
546 @endcode
432bd6b1 547
83e056ab
VZ
548 @since 2.9.1
549 */
550 void LogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info);
432bd6b1 551
83e056ab 552protected:
432bd6b1 553 /**
83e056ab
VZ
554 @name Logging callbacks.
555
556 The functions which should be overridden by custom log targets.
557
558 When defining a new log target, you have a choice between overriding
559 DoLogRecord(), which provides maximal flexibility, DoLogTextAtLevel()
560 which can be used if you don't intend to change the default log
561 messages formatting but want to handle log messages of different levels
562 differently or, in the simplest case, DoLogText().
563 */
564 //@{
565
566 /**
567 Called to log a new record.
568
569 Any log message created by wxLogXXX() functions is passed to this
570 method of the active log target. The default implementation prepends
571 the timestamp and, for some log levels (e.g. error and warning), the
572 corresponding prefix to @a msg and passes it to DoLogTextAtLevel().
573
574 You may override this method to implement custom formatting of the
575 log messages or to implement custom filtering of log messages (e.g. you
576 could discard all log messages coming from the given source file).
577 */
578 virtual void DoLogRecord(wxLogLevel level,
579 const wxString& msg,
580 const wxLogRecordInfo& info);
581
582 /**
583 Called to log the specified string at given level.
584
585 The base class versions logs debug and trace messages on the system
586 default debug output channel and passes all the other messages to
587 DoLogText().
432bd6b1 588 */
83e056ab 589 virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg);
432bd6b1 590
83e056ab
VZ
591 /**
592 Called to log the specified string.
593
594 A simple implementation might just send the string to @c stdout or
595 @c stderr or save it in a file (of course, the already existing
596 wxLogStderr can be used for this).
597
598 The base class version of this function asserts so it must be
599 overridden if you don't override DoLogRecord() or DoLogTextAtLevel().
600 */
601 virtual void DoLogText(const wxString& msg);
602
603 //@}
604};
432bd6b1 605
e54c96f1 606
4ffdb640
VZ
607
608/**
83e056ab 609 @class wxLogChain
4ffdb640 610
83e056ab
VZ
611 This simple class allows you to chain log sinks, that is to install a new sink but
612 keep passing log messages to the old one instead of replacing it completely as
613 wxLog::SetActiveTarget does.
4ffdb640 614
83e056ab
VZ
615 It is especially useful when you want to divert the logs somewhere (for
616 example to a file or a log window) but also keep showing the error messages
617 using the standard dialogs as wxLogGui does by default.
4ffdb640 618
83e056ab 619 Example of usage:
4ffdb640
VZ
620
621 @code
83e056ab 622 wxLogChain *logChain = new wxLogChain(new wxLogStderr);
4ffdb640 623
83e056ab
VZ
624 // all the log messages are sent to stderr and also processed as usually
625 ...
626
627 // don't delete logChain directly as this would leave a dangling
628 // pointer as active log target, use SetActiveTarget() instead
629 delete wxLog::SetActiveTarget(...something else or NULL...);
630 @endcode
4ffdb640
VZ
631
632 @library{wxbase}
633 @category{logging}
4ffdb640 634*/
83e056ab 635class wxLogChain : public wxLog
4ffdb640
VZ
636{
637public:
638 /**
83e056ab
VZ
639 Sets the specified @c logger (which may be @NULL) as the default log
640 target but the log messages are also passed to the previous log target if any.
4ffdb640 641 */
83e056ab 642 wxLogChain(wxLog* logger);
4ffdb640
VZ
643
644 /**
83e056ab
VZ
645 Destroys the previous log target.
646 */
647 virtual ~wxLogChain();
4ffdb640 648
83e056ab
VZ
649 /**
650 Detaches the old log target so it won't be destroyed when the wxLogChain object
651 is destroyed.
652 */
653 void DetachOldLog();
4ffdb640 654
83e056ab
VZ
655 /**
656 Returns the pointer to the previously active log target (which may be @NULL).
4ffdb640 657 */
83e056ab 658 wxLog* GetOldLog() const;
4ffdb640 659
4ffdb640 660 /**
83e056ab
VZ
661 Returns @true if the messages are passed to the previously active log
662 target (default) or @false if PassMessages() had been called.
663 */
664 bool IsPassingMessages() const;
4ffdb640 665
83e056ab
VZ
666 /**
667 By default, the log messages are passed to the previously active log target.
668 Calling this function with @false parameter disables this behaviour
669 (presumably temporarily, as you shouldn't use wxLogChain at all otherwise) and
670 it can be reenabled by calling it again with @a passMessages set to @true.
671 */
672 void PassMessages(bool passMessages);
4ffdb640 673
83e056ab
VZ
674 /**
675 Sets another log target to use (may be @NULL).
4ffdb640 676
83e056ab
VZ
677 The log target specified in the wxLogChain(wxLog*) constructor or in a
678 previous call to this function is deleted.
679 This doesn't change the old log target value (the one the messages are
680 forwarded to) which still remains the same as was active when wxLogChain
681 object was created.
4ffdb640 682 */
83e056ab 683 void SetLog(wxLog* logger);
4ffdb640
VZ
684};
685
686
83e056ab 687
23324ae1 688/**
83e056ab 689 @class wxLogInterposer
7c913512 690
83e056ab
VZ
691 A special version of wxLogChain which uses itself as the new log target.
692 It forwards log messages to the previously installed one in addition to
693 processing them itself.
7c913512 694
83e056ab
VZ
695 Unlike wxLogChain which is usually used directly as is, this class must be
696 derived from to implement wxLog::DoLog and/or wxLog::DoLogString methods.
7c913512 697
83e056ab
VZ
698 wxLogInterposer destroys the previous log target in its destructor.
699 If you don't want this to happen, use wxLogInterposerTemp instead.
a44f3b5a 700
4ffdb640 701 @library{wxbase}
5bc128d6 702 @category{logging}
5bc128d6 703*/
83e056ab 704class wxLogInterposer : public wxLogChain
5bc128d6
RR
705{
706public:
54e280d8 707 /**
83e056ab 708 The default constructor installs this object as the current active log target.
54e280d8 709 */
83e056ab
VZ
710 wxLogInterposer();
711};
3c4f71cc 712
3c4f71cc 713
3c4f71cc 714
83e056ab
VZ
715/**
716 @class wxLogInterposerTemp
3c4f71cc 717
83e056ab
VZ
718 A special version of wxLogChain which uses itself as the new log target.
719 It forwards log messages to the previously installed one in addition to
720 processing them itself. Unlike wxLogInterposer, it doesn't delete the old
721 target which means it can be used to temporarily redirect log output.
6a93e794 722
83e056ab
VZ
723 As per wxLogInterposer, this class must be derived from to implement
724 wxLog::DoLog and/or wxLog::DoLogString methods.
23324ae1 725
83e056ab
VZ
726 @library{wxbase}
727 @category{logging}
728*/
729class wxLogInterposerTemp : public wxLogChain
730{
731public:
ba3af101 732 /**
83e056ab 733 The default constructor installs this object as the current active log target.
54e280d8 734 */
83e056ab
VZ
735 wxLogInterposerTemp();
736};
ba3af101 737
ba3af101 738
83e056ab
VZ
739/**
740 @class wxLogStream
ba3af101 741
83e056ab 742 This class can be used to redirect the log messages to a C++ stream.
232addd1 743
83e056ab
VZ
744 Please note that this class is only available if wxWidgets was compiled with
745 the standard iostream library support (@c wxUSE_STD_IOSTREAM must be on).
232addd1 746
83e056ab
VZ
747 @library{wxbase}
748 @category{logging}
3c4f71cc 749
83e056ab
VZ
750 @see wxLogStderr, wxStreamToTextRedirector
751*/
752class wxLogStream : public wxLog
753{
754public:
755 /**
756 Constructs a log target which sends all the log messages to the given
757 output stream. If it is @NULL, the messages are sent to @c cerr.
23324ae1 758 */
83e056ab
VZ
759 wxLogStream(std::ostream *ostr = NULL);
760};
23324ae1 761
acad886c 762
acad886c 763
83e056ab
VZ
764/**
765 @class wxLogStderr
23324ae1 766
83e056ab
VZ
767 This class can be used to redirect the log messages to a C file stream (not to
768 be confused with C++ streams).
ba3af101 769
83e056ab
VZ
770 It is the default log target for the non-GUI wxWidgets applications which
771 send all the output to @c stderr.
ba3af101 772
83e056ab
VZ
773 @library{wxbase}
774 @category{logging}
23324ae1 775
83e056ab
VZ
776 @see wxLogStream
777*/
778class wxLogStderr : public wxLog
779{
780public:
23324ae1 781 /**
83e056ab
VZ
782 Constructs a log target which sends all the log messages to the given
783 @c FILE. If it is @NULL, the messages are sent to @c stderr.
784 */
785 wxLogStderr(FILE* fp = NULL);
786};
23324ae1 787
23324ae1 788
54e280d8 789
83e056ab
VZ
790/**
791 @class wxLogBuffer
54e280d8 792
83e056ab
VZ
793 wxLogBuffer is a very simple implementation of log sink which simply collects
794 all the logged messages in a string (except the debug messages which are output
795 in the usual way immediately as we're presumably not interested in collecting
796 them for later). The messages from different log function calls are separated
797 by the new lines.
23324ae1 798
83e056ab
VZ
799 All the messages collected so far can be shown to the user (and the current
800 buffer cleared) by calling the overloaded wxLogBuffer::Flush method.
3c4f71cc 801
83e056ab
VZ
802 @library{wxbase}
803 @category{logging}
804*/
805class wxLogBuffer : public wxLog
806{
807public:
23324ae1 808 /**
83e056ab 809 The default ctor does nothing.
23324ae1 810 */
83e056ab 811 wxLogBuffer();
23324ae1 812
23324ae1 813 /**
83e056ab
VZ
814 Shows all the messages collected so far to the user (using a message box in the
815 GUI applications or by printing them out to the console in text mode) and
816 clears the internal buffer.
23324ae1 817 */
83e056ab 818 virtual void Flush();
23324ae1 819
ba3af101 820 /**
83e056ab
VZ
821 Returns the current buffer contains. Messages from different log function calls
822 are separated with the new lines in the buffer.
823 The buffer can be cleared by Flush() which will also show the current
824 contents to the user.
54e280d8 825 */
83e056ab
VZ
826 const wxString& GetBuffer() const;
827};
ba3af101 828
ba3af101 829
ba3af101 830
83e056ab
VZ
831/**
832 @class wxLogNull
c602c59b 833
83e056ab
VZ
834 This class allows you to temporarily suspend logging. All calls to the log
835 functions during the life time of an object of this class are just ignored.
ba3af101 836
83e056ab
VZ
837 In particular, it can be used to suppress the log messages given by wxWidgets
838 itself but it should be noted that it is rarely the best way to cope with this
839 problem as @b all log messages are suppressed, even if they indicate a
840 completely different error than the one the programmer wanted to suppress.
c602c59b 841
83e056ab 842 For instance, the example of the overview:
c602c59b 843
83e056ab
VZ
844 @code
845 wxFile file;
c602c59b 846
83e056ab
VZ
847 // wxFile.Open() normally complains if file can't be opened, we don't want it
848 {
849 wxLogNull logNo;
850 if ( !file.Open("bar") )
851 ... process error ourselves ...
852 } // ~wxLogNull called, old log sink restored
c602c59b 853
83e056ab
VZ
854 wxLogMessage("..."); // ok
855 @endcode
c602c59b 856
83e056ab 857 would be better written as:
c602c59b 858
83e056ab
VZ
859 @code
860 wxFile file;
54e280d8 861
83e056ab
VZ
862 // don't try to open file if it doesn't exist, we are prepared to deal with
863 // this ourselves - but all other errors are not expected
864 if ( wxFile::Exists("bar") )
865 {
866 // gives an error message if the file couldn't be opened
867 file.Open("bar");
868 }
869 else
870 {
871 ...
872 }
873 @endcode
54e280d8 874
23324ae1 875
83e056ab
VZ
876 @library{wxbase}
877 @category{logging}
878*/
879class wxLogNull
880{
881public:
23324ae1 882 /**
83e056ab 883 Suspends logging.
23324ae1 884 */
83e056ab
VZ
885 wxLogNull();
886
acad886c 887 /**
83e056ab
VZ
888 Resumes logging.
889 */
890 ~wxLogNull();
891};
acad886c 892
83e056ab 893#endif // wxUSE_BASE
acad886c 894
83e056ab 895#if wxUSE_GUI
acad886c 896
83e056ab
VZ
897/**
898 @class wxLogWindow
acad886c 899
83e056ab
VZ
900 This class represents a background log window: to be precise, it collects all
901 log messages in the log frame which it manages but also passes them on to the
902 log target which was active at the moment of its creation. This allows you, for
903 example, to show all the log messages in a frame but still continue to process
904 them normally by showing the standard log dialog.
54e280d8 905
83e056ab
VZ
906 @library{wxcore}
907 @category{logging}
54e280d8 908
83e056ab
VZ
909 @see wxLogTextCtrl
910*/
911class wxLogWindow : public wxLogInterposer
912{
913public:
54e280d8 914 /**
83e056ab 915 Creates the log frame window and starts collecting the messages in it.
4ffdb640 916
83e056ab
VZ
917 @param pParent
918 The parent window for the log frame, may be @NULL
919 @param szTitle
920 The title for the log frame
921 @param show
922 @true to show the frame initially (default), otherwise
923 Show() must be called later.
924 @param passToOld
925 @true to process the log messages normally in addition to logging them
926 in the log frame (default), @false to only log them in the log frame.
927 Note that if no targets were set using wxLog::SetActiveTarget() then
928 wxLogWindow simply becomes the active one and messages won't be passed
929 to other targets.
54e280d8 930 */
83e056ab
VZ
931 wxLogWindow(wxWindow* pParent, const wxString& szTitle, bool show = true,
932 bool passToOld = true);
acad886c 933
23324ae1 934 /**
83e056ab
VZ
935 Returns the associated log frame window. This may be used to position or resize
936 it but use Show() to show or hide it.
23324ae1 937 */
83e056ab 938 wxFrame* GetFrame() const;
23324ae1 939
bce9df55 940 /**
83e056ab
VZ
941 Called if the user closes the window interactively, will not be
942 called if it is destroyed for another reason (such as when program
943 exits).
bce9df55 944
83e056ab
VZ
945 Return @true from here to allow the frame to close, @false to
946 prevent this from happening.
4ffdb640 947
83e056ab 948 @see OnFrameDelete()
bce9df55 949 */
83e056ab
VZ
950 virtual bool OnFrameClose(wxFrame* frame);
951
23324ae1 952 /**
83e056ab
VZ
953 Called immediately after the log frame creation allowing for
954 any extra initializations.
23324ae1 955 */
83e056ab 956 virtual void OnFrameCreate(wxFrame* frame);
23324ae1
FM
957
958 /**
83e056ab
VZ
959 Called right before the log frame is going to be deleted: will
960 always be called unlike OnFrameClose().
23324ae1 961 */
83e056ab 962 virtual void OnFrameDelete(wxFrame* frame);
4ffdb640
VZ
963
964 /**
83e056ab
VZ
965 Shows or hides the frame.
966 */
967 void Show(bool show = true);
968};
969
970
971
972/**
973 @class wxLogGui
974
975 This is the default log target for the GUI wxWidgets applications.
976
977 Please see @ref overview_log_customize for explanation of how to change the
978 default log target.
979
980 An object of this class is used by default to show the log messages created
981 by using wxLogMessage(), wxLogError() and other logging functions. It
982 doesn't display the messages logged by them immediately however but
983 accumulates all messages logged during an event handler execution and then
984 shows them all at once when its Flush() method is called during the idle
985 time processing. This has the important advantage of showing only a single
986 dialog to the user even if several messages were logged because of a single
987 error as it often happens (e.g. a low level function could log a message
988 because it failed to open a file resulting in its caller logging another
989 message due to the failure of higher level operation requiring the use of
990 this file). If you need to force the display of all previously logged
991 messages immediately you can use wxLog::FlushActive() to force the dialog
992 display.
993
994 Also notice that if an error message is logged when several informative
995 messages had been already logged before, the informative messages are
996 discarded on the assumption that they are not useful -- and may be
997 confusing and hence harmful -- any more after the error. The warning
998 and error messages are never discarded however and any informational
999 messages logged after the first error one are also kept (as they may
1000 contain information about the error recovery). You may override DoLog()
1001 method to change this behaviour.
4ffdb640 1002
83e056ab
VZ
1003 At any rate, it is possible that that several messages were accumulated
1004 before this class Flush() method is called. If this is the case, Flush()
1005 uses a custom dialog which shows the last message directly and allows the
1006 user to view the previously logged ones by expanding the "Details"
1007 wxCollapsiblePane inside it. This custom dialog also provides the buttons
1008 for copying the log messages to the clipboard and saving them to a file.
4ffdb640 1009
83e056ab
VZ
1010 However if only a single message is present when Flush() is called, just a
1011 wxMessageBox() is used to show it. This has the advantage of being closer
1012 to the native behaviour but it doesn't give the user any possibility to
1013 copy or save the message (except for the recent Windows versions where @c
1014 Ctrl-C may be pressed in the message box to copy its contents to the
1015 clipboard) so you may want to override DoShowSingleLogMessage() to
1016 customize wxLogGui -- the dialogs sample shows how to do this.
4ffdb640 1017
83e056ab
VZ
1018 @library{wxcore}
1019 @category{logging}
1020*/
1021class wxLogGui : public wxLog
1022{
1023public:
1024 /**
1025 Default constructor.
4ffdb640 1026 */
83e056ab 1027 wxLogGui();
23324ae1
FM
1028
1029 /**
83e056ab 1030 Presents the accumulated log messages, if any, to the user.
3c4f71cc 1031
83e056ab
VZ
1032 This method is called during the idle time and should show any messages
1033 accumulated in wxLogGui#m_aMessages field to the user.
1034 */
54e280d8 1035 virtual void Flush();
efce878a 1036
83e056ab
VZ
1037protected:
1038 /**
1039 Returns the appropriate title for the dialog.
efce878a 1040
83e056ab
VZ
1041 The title is constructed from wxApp::GetAppDisplayName() and the
1042 severity string (e.g. "error" or "warning") appropriate for the current
1043 wxLogGui#m_bErrors and wxLogGui#m_bWarnings values.
1044 */
1045 wxString GetTitle() const;
efce878a 1046
83e056ab
VZ
1047 /**
1048 Returns wxICON_ERROR, wxICON_WARNING or wxICON_INFORMATION depending on
1049 the current maximal severity.
efce878a 1050
83e056ab
VZ
1051 This value is suitable to be used in the style parameter of
1052 wxMessageBox() function.
efce878a 1053 */
83e056ab 1054 int GetSeverityIcon() const;
efce878a 1055
bc73d5ae 1056 /**
83e056ab 1057 Forgets all the currently stored messages.
bc73d5ae 1058
83e056ab
VZ
1059 If you override Flush() (and don't call the base class version), you
1060 must call this method to avoid messages being logged over and over
1061 again.
bc73d5ae 1062 */
83e056ab
VZ
1063 void Clear();
1064
5e6e278d
FM
1065
1066 /**
83e056ab 1067 All currently accumulated messages.
bc73d5ae 1068
83e056ab 1069 This array may be empty if no messages were logged.
5e6e278d 1070
83e056ab 1071 @see m_aSeverity, m_aTimes
bc73d5ae 1072 */
83e056ab 1073 wxArrayString m_aMessages;
bc73d5ae
VZ
1074
1075 /**
83e056ab 1076 The severities of each logged message.
bc73d5ae 1077
83e056ab
VZ
1078 This array is synchronized with wxLogGui#m_aMessages, i.e. the n-th
1079 element of this array corresponds to the severity of the n-th message.
1080 The possible severity values are @c wxLOG_XXX constants, e.g.
1081 wxLOG_Error, wxLOG_Warning, wxLOG_Message etc.
1082 */
1083 wxArrayInt m_aSeverity;
5e6e278d
FM
1084
1085 /**
83e056ab 1086 The time stamps of each logged message.
5e6e278d 1087
83e056ab
VZ
1088 The elements of this array are time_t values corresponding to the time
1089 when the message was logged.
1090 */
1091 wxArrayLong m_aTimes;
bc73d5ae 1092
83e056ab
VZ
1093 /**
1094 True if there any error messages.
1095 */
1096 bool m_bErrors;
bc73d5ae 1097
83e056ab
VZ
1098 /**
1099 True if there any warning messages.
23324ae1 1100
83e056ab
VZ
1101 If both wxLogGui#m_bErrors and this member are false, there are only
1102 informational messages to be shown.
1103 */
1104 bool m_bWarnings;
23324ae1 1105
83e056ab
VZ
1106 /**
1107 True if there any messages to be shown to the user.
e54c96f1 1108
83e056ab
VZ
1109 This variable is used instead of simply checking whether
1110 wxLogGui#m_aMessages array is empty to allow blocking further calls to
1111 Flush() while a log dialog is already being shown, even if the messages
1112 array hasn't been emptied yet.
1113 */
1114 bool m_bHasMessages;
7c913512 1115
83e056ab
VZ
1116private:
1117 /**
1118 Method called by Flush() to show a single log message.
7c913512 1119
83e056ab
VZ
1120 This function can be overridden to show the message in a different way.
1121 By default a simple wxMessageBox() call is used.
7c913512 1122
83e056ab
VZ
1123 @param message
1124 The message to show (it can contain multiple lines).
1125 @param title
1126 The suggested title for the dialog showing the message, see
1127 GetTitle().
1128 @param style
1129 One of @c wxICON_XXX constants, see GetSeverityIcon().
1130 */
1131 virtual void DoShowSingleLogMessage(const wxString& message,
1132 const wxString& title,
1133 int style);
7c913512 1134
83e056ab
VZ
1135 /**
1136 Method called by Flush() to show multiple log messages.
7c913512 1137
83e056ab
VZ
1138 This function can be overridden to show the messages in a different way.
1139 By default a special log dialog showing the most recent message and
1140 allowing the user to expand it to view the previously logged ones is
1141 used.
7c913512 1142
83e056ab
VZ
1143 @param messages
1144 Array of messages to show; it contains more than one element.
1145 @param severities
1146 Array of message severities containing @c wxLOG_XXX values.
1147 @param times
1148 Array of time_t values indicating when each message was logged.
1149 @param title
1150 The suggested title for the dialog showing the message, see
1151 GetTitle().
1152 @param style
1153 One of @c wxICON_XXX constants, see GetSeverityIcon().
1154 */
1155 virtual void DoShowMultipleLogMessages(const wxArrayString& messages,
1156 const wxArrayInt& severities,
1157 const wxArrayLong& times,
1158 const wxString& title,
1159 int style);
1160};
7c913512 1161
7c913512 1162
7c913512 1163
83e056ab
VZ
1164/**
1165 @class wxLogTextCtrl
7c913512 1166
83e056ab
VZ
1167 Using these target all the log messages can be redirected to a text control.
1168 The text control must have been created with @c wxTE_MULTILINE style by the
1169 caller previously.
7c913512 1170
83e056ab 1171 @library{wxcore}
23324ae1 1172 @category{logging}
83e056ab
VZ
1173
1174 @see wxTextCtrl, wxStreamToTextRedirector
23324ae1 1175*/
83e056ab 1176class wxLogTextCtrl : public wxLog
23324ae1
FM
1177{
1178public:
1179 /**
83e056ab
VZ
1180 Constructs a log target which sends all the log messages to the given text
1181 control. The @a textctrl parameter cannot be @NULL.
23324ae1 1182 */
83e056ab 1183 wxLogTextCtrl(wxTextCtrl* pTextCtrl);
23324ae1
FM
1184};
1185
1186
83e056ab
VZ
1187#endif // wxUSE_GUI
1188
1189#if wxUSE_BASE
1190
e54c96f1 1191
23324ae1
FM
1192// ============================================================================
1193// Global functions/macros
1194// ============================================================================
1195
b21126db 1196/** @addtogroup group_funcmacro_log */
ef477678
BP
1197//@{
1198
23324ae1 1199/**
ef477678
BP
1200 This function shows a message to the user in a safe way and should be safe
1201 to call even before the application has been initialized or if it is
1202 currently in some other strange state (for example, about to crash). Under
1203 Windows this function shows a message box using a native dialog instead of
1204 wxMessageBox() (which might be unsafe to call), elsewhere it simply prints
1205 the message to the standard output using the title as prefix.
7c913512
FM
1206
1207 @param title
ef477678
BP
1208 The title of the message box shown to the user or the prefix of the
1209 message string.
7c913512 1210 @param text
ef477678 1211 The text to show to the user.
7c913512 1212
e54c96f1 1213 @see wxLogFatalError()
ef477678
BP
1214
1215 @header{wx/log.h}
23324ae1 1216*/
ef477678
BP
1217void wxSafeShowMessage(const wxString& title, const wxString& text);
1218
1219/**
1220 Returns the error code from the last system call. This function uses
1221 @c errno on Unix platforms and @c GetLastError under Win32.
23324ae1 1222
ef477678 1223 @see wxSysErrorMsg(), wxLogSysError()
96d7cc9b 1224
ef477678
BP
1225 @header{wx/log.h}
1226*/
1227unsigned long wxSysErrorCode();
96d7cc9b 1228
ef477678
BP
1229/**
1230 Returns the error message corresponding to the given system error code. If
1231 @a errCode is 0 (default), the last error code (as returned by
1232 wxSysErrorCode()) is used.
1233
1234 @see wxSysErrorCode(), wxLogSysError()
1235
1236 @header{wx/log.h}
1237*/
1238const wxChar* wxSysErrorMsg(unsigned long errCode = 0);
1239
1240//@}
1241
75e488d5
FM
1242/** @addtogroup group_funcmacro_log */
1243//@{
1244/**
1245 Logs a message with the given wxLogLevel.
1246 E.g. using @c wxLOG_Message as first argument, this function behaves like wxLogMessage().
1247
1248 @header{wx/log.h}
1249*/
1250void wxLogGeneric(wxLogLevel level, const char* formatString, ... );
1251void wxVLogGeneric(wxLogLevel level, const char* formatString, va_list argPtr);
1252//@}
1253
b21126db 1254/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1255//@{
1256/**
ef477678
BP
1257 For all normal, informational messages. They also appear in a message box
1258 by default (but it can be changed).
1259
1260 @header{wx/log.h}
96d7cc9b
FM
1261*/
1262void wxLogMessage(const char* formatString, ... );
1263void wxVLogMessage(const char* formatString, va_list argPtr);
1264//@}
1265
b21126db 1266/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1267//@{
1268/**
ef477678
BP
1269 For verbose output. Normally, it is suppressed, but might be activated if
1270 the user wishes to know more details about the program progress (another,
1271 but possibly confusing name for the same function could be @c wxLogInfo).
1272
1273 @header{wx/log.h}
96d7cc9b
FM
1274*/
1275void wxLogVerbose(const char* formatString, ... );
1276void wxVLogVerbose(const char* formatString, va_list argPtr);
1277//@}
1278
b21126db 1279/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1280//@{
1281/**
ef477678
BP
1282 For warnings - they are also normally shown to the user, but don't
1283 interrupt the program work.
1284
1285 @header{wx/log.h}
96d7cc9b
FM
1286*/
1287void wxLogWarning(const char* formatString, ... );
1288void wxVLogWarning(const char* formatString, va_list argPtr);
1289//@}
1290
b21126db 1291/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1292//@{
1293/**
ef477678
BP
1294 Like wxLogError(), but also terminates the program with the exit code 3.
1295 Using @e abort() standard function also terminates the program with this
1296 exit code.
1297
1298 @header{wx/log.h}
96d7cc9b
FM
1299*/
1300void wxLogFatalError(const char* formatString, ... );
ef477678 1301void wxVLogFatalError(const char* formatString, va_list argPtr);
96d7cc9b
FM
1302//@}
1303
b21126db 1304/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1305//@{
1306/**
ef477678
BP
1307 The functions to use for error messages, i.e. the messages that must be
1308 shown to the user. The default processing is to pop up a message box to
1309 inform the user about it.
1310
1311 @header{wx/log.h}
96d7cc9b
FM
1312*/
1313void wxLogError(const char* formatString, ... );
1314void wxVLogError(const char* formatString, va_list argPtr);
1315//@}
1316
b21126db 1317/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1318//@{
1319/**
695d5232 1320 Log a message at @c wxLOG_Trace log level (see ::wxLogLevelValues enum).
7bfc1038
VZ
1321
1322 Notice that the use of trace masks is not recommended any more as setting
1323 the log components (please see @ref overview_log_enable) provides a way to
1324 do the same thing for log messages of any level, and not just the tracing
1325 ones.
1326
ef477678
BP
1327 Like wxLogDebug(), trace functions only do something in debug builds and
1328 expand to nothing in the release one. The reason for making it a separate
1329 function is that usually there are a lot of trace messages, so it might
1330 make sense to separate them from other debug messages.
1331
695d5232
FM
1332 Trace messages can be separated into different categories; these functions in facts
1333 only log the message if the given @a mask is currently enabled in wxLog.
1334 This lets you selectively trace only some operations and not others by enabling the
1335 desired trace masks with wxLog::AddTraceMask() or by setting the
ef477678
BP
1336 @ref overview_envvars "@c WXTRACE environment variable".
1337
1338 The predefined string trace masks used by wxWidgets are:
1339
1340 @beginDefList
1341 @itemdef{ wxTRACE_MemAlloc, Trace memory allocation (new/delete) }
1342 @itemdef{ wxTRACE_Messages, Trace window messages/X callbacks }
1343 @itemdef{ wxTRACE_ResAlloc, Trace GDI resource allocation }
1344 @itemdef{ wxTRACE_RefCount, Trace various ref counting operations }
1345 @itemdef{ wxTRACE_OleCalls, Trace OLE method calls (Win32 only) }
1346 @endDefList
1347
ef477678
BP
1348 @header{wx/log.h}
1349*/
1350void wxLogTrace(const char* mask, const char* formatString, ... );
695d5232 1351void wxVLogTrace(const char* mask, const char* formatString, va_list argPtr);
96d7cc9b
FM
1352//@}
1353
b21126db 1354/** @addtogroup group_funcmacro_log */
ef477678
BP
1355//@{
1356/**
1357 Like wxLogDebug(), trace functions only do something in debug builds and
1358 expand to nothing in the release one. The reason for making it a separate
1359 function is that usually there are a lot of trace messages, so it might
1360 make sense to separate them from other debug messages.
1361
22f24132 1362 @deprecated
ef477678
BP
1363 This version of wxLogTrace() only logs the message if all the bits
1364 corresponding to the @a mask are set in the wxLog trace mask which can be
1365 set by calling wxLog::SetTraceMask(). This version is less flexible than
34085a0d 1366 wxLogTrace(const char*,const char*,...) because it doesn't allow defining
ef477678
BP
1367 the user trace masks easily. This is why it is deprecated in favour of
1368 using string trace masks.
1369
1370 The following bitmasks are defined for wxTraceMask:
1371
1372 @beginDefList
1373 @itemdef{ wxTraceMemAlloc, Trace memory allocation (new/delete) }
1374 @itemdef{ wxTraceMessages, Trace window messages/X callbacks }
1375 @itemdef{ wxTraceResAlloc, Trace GDI resource allocation }
1376 @itemdef{ wxTraceRefCount, Trace various ref counting operations }
1377 @itemdef{ wxTraceOleCalls, Trace OLE method calls (Win32 only) }
1378 @endDefList
1379
1380 @header{wx/log.h}
1381*/
1382void wxLogTrace(wxTraceMask mask, const char* formatString, ... );
1383void wxVLogTrace(wxTraceMask mask, const char* formatString, va_list argPtr);
1384//@}
96d7cc9b 1385
b21126db 1386/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1387//@{
1388/**
ef477678
BP
1389 The right functions for debug output. They only do something in debug mode
1390 (when the preprocessor symbol @c __WXDEBUG__ is defined) and expand to
96d7cc9b 1391 nothing in release mode (otherwise).
ef477678
BP
1392
1393 @header{wx/log.h}
96d7cc9b
FM
1394*/
1395void wxLogDebug(const char* formatString, ... );
1396void wxVLogDebug(const char* formatString, va_list argPtr);
1397//@}
1398
b21126db 1399/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1400//@{
1401/**
ef477678
BP
1402 Messages logged by this function will appear in the statusbar of the
1403 @a frame or of the top level application window by default (i.e. when using
96d7cc9b 1404 the second version of the functions).
ef477678 1405
96d7cc9b 1406 If the target frame doesn't have a statusbar, the message will be lost.
ef477678
BP
1407
1408 @header{wx/log.h}
96d7cc9b 1409*/
ef477678
BP
1410void wxLogStatus(wxFrame* frame, const char* formatString, ... );
1411void wxVLogStatus(wxFrame* frame, const char* formatString, va_list argPtr);
96d7cc9b
FM
1412void wxLogStatus(const char* formatString, ... );
1413void wxVLogStatus(const char* formatString, va_list argPtr);
1414//@}
1415
b21126db 1416/** @addtogroup group_funcmacro_log */
96d7cc9b
FM
1417//@{
1418/**
ef477678
BP
1419 Mostly used by wxWidgets itself, but might be handy for logging errors
1420 after system call (API function) failure. It logs the specified message
deed8373 1421 text as well as the last system error code (@e errno or @e GetLastError()
ef477678
BP
1422 depending on the platform) and the corresponding error message. The second
1423 form of this function takes the error code explicitly as the first
1424 argument.
96d7cc9b
FM
1425
1426 @see wxSysErrorCode(), wxSysErrorMsg()
ef477678
BP
1427
1428 @header{wx/log.h}
96d7cc9b
FM
1429*/
1430void wxLogSysError(const char* formatString, ... );
ef477678 1431void wxVLogSysError(const char* formatString, va_list argPtr);
39fb8056
FM
1432//@}
1433
7d9550df
VZ
1434/** @addtogroup group_funcmacro_debug */
1435//@{
1436
1437/**
1438 @def wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD()
1439
1440 Use this macro to disable logging at debug and trace levels in release
e4431849 1441 build when not using wxIMPLEMENT_APP().
7d9550df
VZ
1442
1443 @see wxDISABLE_DEBUG_SUPPORT(),
1444 wxDISABLE_ASSERTS_IN_RELEASE_BUILD(),
1445 @ref overview_debugging
1446
1447 @since 2.9.1
1448
1449 @header{wx/log.h}
1450 */
1451#define wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD()
1452
1453//@}
1454
83e056ab 1455#endif // wxUSE_BASE