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