]>
Commit | Line | Data |
---|---|---|
4a20e756 VZ |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: log.tex | |
3 | %% Purpose: wxLog and related classes documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: some time ago | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) 1997-2001 Vadim Zeitlin | |
8795498c | 9 | %% License: wxWindows license |
4a20e756 VZ |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | ||
9ee2d31c VZ |
12 | \section{\class{wxLog}}\label{wxlog} |
13 | ||
fc2171bd | 14 | wxLog class defines the interface for the {\it log targets} used by wxWidgets |
9ee2d31c VZ |
15 | logging functions as explained in the \helpref{wxLog overview}{wxlogoverview}. |
16 | The only situations when you need to directly use this class is when you want | |
17 | to derive your own log target because the existing ones don't satisfy your | |
18 | needs. Another case is if you wish to customize the behaviour of the standard | |
19 | logging classes (all of which respect the wxLog settings): for example, set | |
20 | which trace messages are logged and which are not or change (or even remove | |
21 | completely) the timestamp on the messages. | |
22 | ||
23 | Otherwise, it is completely hidden behind the {\it wxLogXXX()} functions and | |
24 | you may not even know about its existence. | |
25 | ||
fc2171bd | 26 | See \helpref{log overview}{wxlogoverview} for the descriptions of wxWidgets |
9ee2d31c VZ |
27 | logging facilities. |
28 | ||
29 | \wxheading{Derived from} | |
30 | ||
31 | No base class | |
32 | ||
954b8ae6 JS |
33 | \wxheading{Include files} |
34 | ||
35 | <wx/log.h> | |
36 | ||
a7af285d VZ |
37 | \wxheading{Library} |
38 | ||
39 | \helpref{wxCore}{librarieslist} | |
40 | ||
9ee2d31c VZ |
41 | \latexignore{\rtfignore{\wxheading{Function groups}}} |
42 | ||
615c6433 | 43 | \membersection{Global functions} |
9ee2d31c VZ |
44 | |
45 | The functions in this section work with and manipulate the active log target. | |
4a20e756 VZ |
46 | The \helpref{OnLog()}{wxlogonlog} is called by the {\it wxLogXXX()} functions |
47 | and invokes the \helpref{DoLog()}{wxlogdolog} of the active log target if any. | |
48 | Get/Set methods are used to install/query the current active target and, | |
49 | finally, \helpref{DontCreateOnDemand()}{wxlogdontcreateondemand} disables the | |
50 | automatic creation of a standard log target if none actually exists. It is | |
51 | only useful when the application is terminating and shouldn't be used in other | |
52 | situations because it may easily lead to a loss of messages. | |
9ee2d31c VZ |
53 | |
54 | \helpref{OnLog}{wxlogonlog}\\ | |
55 | \helpref{GetActiveTarget}{wxloggetactivetarget}\\ | |
42ff6409 | 56 | \helpref{SetActiveTarget}{wxlogsetactivetarget}\\ |
b6b1d47f VZ |
57 | \helpref{DontCreateOnDemand}{wxlogdontcreateondemand}\\ |
58 | \helpref{Suspend}{wxlogsuspend}\\ | |
59 | \helpref{Resume}{wxlogresume} | |
9ee2d31c | 60 | |
dcbd177f | 61 | \membersection{Logging functions}\label{loggingfunctions} |
4a20e756 VZ |
62 | |
63 | There are two functions which must be implemented by any derived class to | |
edc73852 | 64 | actually process the log messages: \helpref{DoLog}{wxlogdolog} and |
4a20e756 VZ |
65 | \helpref{DoLogString}{wxlogdologstring}. The second function receives a string |
66 | which just has to be output in some way and the easiest way to write a new log | |
67 | target is to override just this function in the derived class. If more control | |
68 | over the output format is needed, then the first function must be overridden | |
69 | which allows to construct custom messages depending on the log level or even | |
70 | do completely different things depending on the message severity (for example, | |
71 | throw away all messages except warnings and errors, show warnings on the | |
72 | screen and forward the error messages to the user's (or programmer's) cell | |
73 | phone - maybe depending on whether the timestamp tells us if it is day or | |
74 | night in the current time zone). | |
75 | ||
76 | There also functions to support message buffering. Why are they needed? | |
77 | Some of wxLog implementations, most notably the standard wxLogGui class, | |
78 | buffer the messages (for example, to avoid showing the user a zillion of modal | |
1ec5cbf3 | 79 | message boxes one after another -- which would be really annoying). |
4a20e756 | 80 | \helpref{Flush()}{wxlogflush} shows them all and clears the buffer contents. |
1ec5cbf3 | 81 | This function doesn't do anything if the buffer is already empty. |
9ee2d31c VZ |
82 | |
83 | \helpref{Flush}{wxlogflush}\\ | |
1ec5cbf3 | 84 | \helpref{FlushActive}{wxlogflushactive} |
9ee2d31c | 85 | |
42ff6409 | 86 | \membersection{Customization}\label{wxlogcustomization} |
9ee2d31c VZ |
87 | |
88 | The functions below allow some limited customization of wxLog behaviour | |
89 | without writing a new log target class (which, aside of being a matter of | |
90 | several minutes, allows you to do anything you want). | |
91 | ||
92 | The verbose messages are the trace messages which are not disabled in the | |
fe482327 SB |
93 | release mode and are generated by \helpref{wxLogVerbose}{wxlogverbose}. They |
94 | are not normally shown to the user because they present little interest, but | |
95 | may be activated, for example, in order to help the user find some program | |
96 | problem. | |
9ee2d31c | 97 | |
ac7f0167 VZ |
98 | As for the (real) trace messages, their handling depends on the settings of |
99 | the (application global) {\it trace mask}. There are two ways to specify it: | |
edc73852 RD |
100 | either by using \helpref{SetTraceMask}{wxlogsettracemask} and |
101 | \helpref{GetTraceMask}{wxloggettracemask} and using | |
102 | \helpref{wxLogTrace}{wxlogtrace} which takes an integer mask or by using | |
ac7f0167 VZ |
103 | \helpref{AddTraceMask}{wxlogaddtracemask} for string trace masks. |
104 | ||
105 | The difference between bit-wise and string trace masks is that a message using | |
106 | integer trace mask will only be logged if all bits of the mask are set in the | |
107 | current mask while a message using string mask will be logged simply if the | |
108 | mask had been added before to the list of allowed ones. | |
109 | ||
110 | For example, | |
fa482912 | 111 | |
ac7f0167 VZ |
112 | \begin{verbatim} |
113 | // wxTraceOleCalls is one of standard bit masks | |
114 | wxLogTrace(wxTraceRefCount | wxTraceOleCalls, "Active object ref count: %d", nRef); | |
115 | \end{verbatim} | |
edc73852 | 116 | will do something only if the current trace mask contains both |
ac7f0167 | 117 | {\tt wxTraceRefCount} and {\tt wxTraceOle}, but |
fa482912 | 118 | |
ac7f0167 VZ |
119 | \begin{verbatim} |
120 | // wxTRACE_OleCalls is one of standard string masks | |
fe482327 | 121 | wxLogTrace(wxTRACE_OleCalls, "IFoo::Bar() called"); |
ac7f0167 | 122 | \end{verbatim} |
fa482912 | 123 | |
ac7f0167 | 124 | will log the message if it was preceded by |
fa482912 | 125 | |
9ee2d31c | 126 | \begin{verbatim} |
ac7f0167 | 127 | wxLog::AddTraceMask(wxTRACE_OleCalls); |
9ee2d31c | 128 | \end{verbatim} |
ac7f0167 VZ |
129 | |
130 | Using string masks is simpler and allows to easily add custom ones, so this is | |
131 | the preferred way of working with trace messages. The integer trace mask is | |
132 | kept for compatibility and for additional (but very rarely needed) flexibility | |
133 | only. | |
134 | ||
edc73852 | 135 | The standard trace masks are given in \helpref{wxLogTrace}{wxlogtrace} |
ac7f0167 | 136 | documentation. |
9ee2d31c VZ |
137 | |
138 | Finally, the {\it wxLog::DoLog()} function automatically prepends a time stamp | |
139 | to all the messages. The format of the time stamp may be changed: it can be | |
2edb0bde | 140 | any string with \% specifications fully described in the documentation of the |
9ee2d31c VZ |
141 | standard {\it strftime()} function. For example, the default format is |
142 | "[\%d/\%b/\%y \%H:\%M:\%S] " which gives something like "[17/Sep/98 22:10:16] " | |
143 | (without quotes) for the current date. Setting an empty string as the time | |
144 | format disables timestamping of the messages completely. | |
145 | ||
ac7f0167 VZ |
146 | {\bf NB:} Timestamping is disabled for Visual C++ users in debug builds by |
147 | default because otherwise it would be impossible to directly go to the line | |
148 | from which the log message was generated by simply clicking in the debugger | |
edc73852 | 149 | window on the corresponding error message. If you wish to enable it, please use |
ac7f0167 VZ |
150 | \helpref{SetTimestamp}{wxlogsettimestamp} explicitly. |
151 | ||
152 | \helpref{AddTraceMask}{wxlogaddtracemask}\\ | |
153 | \helpref{RemoveTraceMask}{wxlogremovetracemask}\\ | |
36bd6902 | 154 | \helpref{ClearTraceMasks}{wxlogcleartracemasks}\\ |
0e080be6 | 155 | \helpref{GetTraceMasks}{wxloggettracemasks}\\ |
ac7f0167 | 156 | \helpref{IsAllowedTraceMask}{wxlogisallowedtracemask}\\ |
9ee2d31c VZ |
157 | \helpref{SetVerbose}{wxlogsetverbose}\\ |
158 | \helpref{GetVerbose}{wxloggetverbose}\\ | |
22d6efa8 JS |
159 | \helpref{SetTimestamp}{wxlogsettimestamp}\\ |
160 | \helpref{GetTimestamp}{wxloggettimestamp}\\ | |
9ee2d31c | 161 | \helpref{SetTraceMask}{wxlogsettracemask}\\ |
f9837791 VZ |
162 | \helpref{GetTraceMask}{wxloggettracemask}\\ |
163 | \helpref{SetRepetitionCounting}{wxlogsetrepetitioncounting}\\ | |
164 | \helpref{GetRepetitionCounting}{wxloggetrepetitioncounting} | |
9ee2d31c VZ |
165 | |
166 | %%%%% MEMBERS HERE %%%%% | |
167 | \helponly{\insertatlevel{2}{ | |
168 | ||
169 | \wxheading{Members} | |
170 | ||
171 | }} | |
172 | ||
ac7f0167 VZ |
173 | \membersection{wxLog::AddTraceMask}\label{wxlogaddtracemask} |
174 | ||
175 | \func{static void}{AddTraceMask}{\param{const wxString\& }{mask}} | |
176 | ||
edc73852 | 177 | Add the {\it mask} to the list of allowed masks for |
ac7f0167 VZ |
178 | \helpref{wxLogTrace}{wxlogtrace}. |
179 | ||
0e080be6 | 180 | \wxheading{See also} |
d2c2afc9 | 181 | |
0e080be6 RL |
182 | \helpref{RemoveTraceMask}{wxlogremovetracemask} |
183 | \helpref{GetTraceMasks}{wxloggettracemasks} | |
ac7f0167 | 184 | |
36bd6902 VZ |
185 | \membersection{wxLog::ClearTraceMasks}\label{wxlogcleartracemasks} |
186 | ||
187 | \func{static void}{ClearTraceMasks}{\void} | |
188 | ||
edc73852 | 189 | Removes all trace masks previously set with |
36bd6902 VZ |
190 | \helpref{AddTraceMask}{wxlogaddtracemask}. |
191 | ||
0e080be6 | 192 | \wxheading{See also} |
d2c2afc9 | 193 | |
0e080be6 RL |
194 | \helpref{RemoveTraceMask}{wxlogremovetracemask} |
195 | ||
196 | \membersection{wxLog::GetTraceMasks}\label{wxloggettracemasks} | |
197 | ||
bf43ff9a | 198 | \func{static const wxArrayString \&}{GetTraceMasks}{\void} |
0e080be6 RL |
199 | |
200 | Returns the currently allowed list of string trace masks. | |
201 | ||
202 | \wxheading{See also} | |
d2c2afc9 | 203 | |
0e080be6 | 204 | \helpref{AddTraceMask}{wxlogaddtracemask}. |
36bd6902 | 205 | |
9ee2d31c VZ |
206 | \membersection{wxLog::OnLog}\label{wxlogonlog} |
207 | ||
5a20d2ce | 208 | \func{static void}{OnLog}{\param{wxLogLevel }{ level}, \param{const wxString\& }{ message}} |
9ee2d31c VZ |
209 | |
210 | Forwards the message at specified level to the {\it DoLog()} function of the | |
211 | active log target if there is any, does nothing otherwise. | |
212 | ||
213 | \membersection{wxLog::GetActiveTarget}\label{wxloggetactivetarget} | |
214 | ||
215 | \func{static wxLog *}{GetActiveTarget}{\void} | |
216 | ||
217 | Returns the pointer to the active log target (may be NULL). | |
218 | ||
219 | \membersection{wxLog::SetActiveTarget}\label{wxlogsetactivetarget} | |
220 | ||
221 | \func{static wxLog *}{SetActiveTarget}{\param{wxLog * }{ logtarget}} | |
222 | ||
223 | Sets the specified log target as the active one. Returns the pointer to the | |
154b6b0f | 224 | previous active log target (may be NULL). To suppress logging use a new |
77d47192 DE |
225 | instance of wxLogNull not NULL. If the active log target is set to NULL a |
226 | new default log target will be created when logging occurs. | |
9ee2d31c | 227 | |
b6b1d47f VZ |
228 | \membersection{wxLog::Suspend}\label{wxlogsuspend} |
229 | ||
230 | \func{static void}{Suspend}{\void} | |
231 | ||
232 | Suspends the logging until \helpref{Resume}{wxlogresume} is called. Note that | |
233 | the latter must be called the same number of times as the former to undo it, | |
234 | i.e. if you call Suspend() twice you must call Resume() twice as well. | |
235 | ||
236 | Note that suspending the logging means that the log sink won't be be flushed | |
237 | periodically, it doesn't have any effect if the current log target does the | |
238 | logging immediately without waiting for \helpref{Flush}{wxlogflush} to be | |
239 | called (the standard GUI log target only shows the log dialog when it is | |
240 | flushed, so Suspend() works as expected with it). | |
241 | ||
d2c2afc9 | 242 | \wxheading{See also} |
b6b1d47f VZ |
243 | |
244 | \helpref{Resume}{wxlogresume},\\ | |
245 | \helpref{wxLogNull}{wxlogoverview} | |
246 | ||
247 | \membersection{wxLog::Resume}\label{wxlogresume} | |
248 | ||
249 | \func{static void}{Resume}{\void} | |
250 | ||
edc73852 | 251 | Resumes logging previously suspended by a call to |
9148009b | 252 | \helpref{Suspend}{wxlogsuspend}. All messages logged in the meanwhile will be |
b6b1d47f VZ |
253 | flushed soon. |
254 | ||
4a20e756 VZ |
255 | \membersection{wxLog::DoLog}\label{wxlogdolog} |
256 | ||
5a20d2ce | 257 | \func{virtual void}{DoLog}{\param{wxLogLevel }{level}, \param{const wxString\& }{msg}, \param{time\_t }{timestamp}} |
4a20e756 VZ |
258 | |
259 | Called to process the message of the specified severity. {\it msg} is the text | |
260 | of the message as specified in the call of {\it wxLogXXX()} function which | |
261 | generated it and {\it timestamp} is the moment when the message was generated. | |
262 | ||
263 | The base class version prepends the timestamp to the message, adds a prefix | |
edc73852 | 264 | corresponding to the log level and then calls |
4a20e756 VZ |
265 | \helpref{DoLogString}{wxlogdologstring} with the resulting string. |
266 | ||
267 | \membersection{wxLog::DoLogString}\label{wxlogdologstring} | |
268 | ||
5a20d2ce | 269 | \func{virtual void}{DoLogString}{\param{const wxString\& }{msg}, \param{time\_t }{timestamp}} |
4a20e756 | 270 | |
fab86f26 | 271 | Called to log the specified string. The timestamp is already included in the |
4a20e756 VZ |
272 | string but still passed to this function. |
273 | ||
edc73852 | 274 | A simple implementation may just send the string to {\tt stdout} or, better, |
4a20e756 VZ |
275 | {\tt stderr}. |
276 | ||
9ee2d31c VZ |
277 | \membersection{wxLog::DontCreateOnDemand}\label{wxlogdontcreateondemand} |
278 | ||
279 | \func{static void}{DontCreateOnDemand}{\void} | |
280 | ||
281 | Instructs wxLog to not create new log targets on the fly if there is none | |
36bd6902 VZ |
282 | currently. (Almost) for internal use only: it is supposed to be called by the |
283 | application shutdown code. | |
284 | ||
edc73852 | 285 | Note that this function also calls |
36bd6902 | 286 | \helpref{ClearTraceMasks}{wxlogcleartracemasks}. |
9ee2d31c | 287 | |
42ff6409 | 288 | \membersection{wxLog::Flush}\label{wxlogflush} |
9ee2d31c VZ |
289 | |
290 | \func{virtual void}{Flush}{\void} | |
291 | ||
292 | Shows all the messages currently in buffer and clears it. If the buffer | |
293 | is already empty, nothing happens. | |
294 | ||
e1ea357c VZ |
295 | \membersection{wxLog::FlushActive}\label{wxlogflushactive} |
296 | ||
297 | \func{static void}{FlushActive}{\void} | |
298 | ||
299 | Flushes the current log target if any, does nothing if there is none. | |
300 | ||
d2c2afc9 | 301 | \wxheading{See also} |
e1ea357c VZ |
302 | |
303 | \helpref{Flush}{wxlogflush} | |
304 | ||
42ff6409 | 305 | \membersection{wxLog::SetVerbose}\label{wxlogsetverbose} |
9ee2d31c | 306 | |
cc81d32f | 307 | \func{static void}{SetVerbose}{\param{bool }{ verbose = true}} |
9ee2d31c | 308 | |
2edb0bde | 309 | Activates or deactivates verbose mode in which the verbose messages are |
9ee2d31c VZ |
310 | logged as the normal ones instead of being silently dropped. |
311 | ||
42ff6409 | 312 | \membersection{wxLog::GetVerbose}\label{wxloggetverbose} |
9ee2d31c | 313 | |
4a20e756 | 314 | \func{static bool}{GetVerbose}{\void} |
9ee2d31c VZ |
315 | |
316 | Returns whether the verbose mode is currently active. | |
317 | ||
edc73852 RD |
318 | \membersection{wxLog::SetLogLevel}\label{wxlogsetloglevel} |
319 | ||
320 | \func{static void}{SetLogLevel}{\param{wxLogLevel }{ logLevel}} | |
321 | ||
322 | Specifies that log messages with $level > logLevel$ should be ignored | |
323 | and not sent to the active log target. | |
324 | ||
325 | \membersection{wxLog::GetLogLevel}\label{wxloggetloglevel} | |
326 | ||
327 | \func{static wxLogLevel}{GetLogLevel}{\void} | |
328 | ||
329 | Returns the current log level limit. | |
330 | ||
f9837791 VZ |
331 | \membersection{wxLog::SetRepetitionCounting}\label{wxlogsetrepetitioncounting} |
332 | ||
333 | \func{static void}{SetRepetitionCounting}{\param{bool }{ repetCounting = true}} | |
334 | ||
335 | Enables logging mode in which a log message is logged once, and in case exactly | |
336 | the same message successively repeats one or more times, only the number of | |
337 | repetitions is logged. | |
338 | ||
339 | \membersection{wxLog::GetRepetitionCounting}\label{wxloggetrepetitioncounting} | |
340 | ||
341 | \func{static bool}{GetRepetitionCounting}{\void} | |
342 | ||
343 | Returns whether the repetition counting mode is enabled. | |
344 | ||
345 | ||
22d6efa8 | 346 | \membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp} |
9ee2d31c | 347 | |
7b1bf3ad | 348 | \func{static void}{SetTimestamp}{\param{const wxString\&}{ format}} |
9ee2d31c VZ |
349 | |
350 | Sets the timestamp format prepended by the default log targets to all | |
351 | messages. The string may contain any normal characters as well as \% | |
352 | prefixed format specificators, see {\it strftime()} manual for details. | |
7b1bf3ad VZ |
353 | Passing an empty string to this function disables message time stamping. |
354 | ||
355 | \membersection{wxLog::DisableTimestamp}\label{wxlogdisabletimestamp} | |
356 | ||
357 | \func{void}{SetTimestamp}{\param{const wxString\&}{ format}} | |
358 | ||
359 | Disables time stamping of the log messages. | |
360 | ||
361 | \newsince{2.9} | |
9ee2d31c | 362 | |
22d6efa8 | 363 | \membersection{wxLog::GetTimestamp}\label{wxloggettimestamp} |
9ee2d31c | 364 | |
7b1bf3ad | 365 | \func{static const wxString\&}{GetTimestamp}{\void} |
9ee2d31c VZ |
366 | |
367 | Returns the current timestamp format string. | |
368 | ||
42ff6409 | 369 | \membersection{wxLog::SetTraceMask}\label{wxlogsettracemask} |
9ee2d31c VZ |
370 | |
371 | \func{static void}{SetTraceMask}{\param{wxTraceMask }{ mask}} | |
372 | ||
373 | Sets the trace mask, see \helpref{Customization}{wxlogcustomization} | |
374 | section for details. | |
375 | ||
42ff6409 | 376 | \membersection{wxLog::GetTraceMask}\label{wxloggettracemask} |
7b1bf3ad VZ |
377 | |
378 | \func{static wxTraceMask}{GetTraceMask}{\void} | |
9ee2d31c | 379 | |
42ff6409 JS |
380 | Returns the current trace mask, see \helpref{Customization}{wxlogcustomization} section |
381 | for details. | |
62448488 | 382 | |
ac7f0167 VZ |
383 | \membersection{wxLog::IsAllowedTraceMask}\label{wxlogisallowedtracemask} |
384 | ||
5a20d2ce | 385 | \func{static bool}{IsAllowedTraceMask}{\param{const wxString\& }{mask}} |
ac7f0167 | 386 | |
cc81d32f | 387 | Returns true if the {\it mask} is one of allowed masks for |
ac7f0167 VZ |
388 | \helpref{wxLogTrace}{wxlogtrace}. |
389 | ||
edc73852 | 390 | See also: \helpref{AddTraceMask}{wxlogaddtracemask}, |
ac7f0167 VZ |
391 | \helpref{RemoveTraceMask}{wxlogremovetracemask} |
392 | ||
393 | \membersection{wxLog::RemoveTraceMask}\label{wxlogremovetracemask} | |
394 | ||
395 | \func{static void}{RemoveTraceMask}{\param{const wxString\& }{mask}} | |
396 | ||
edc73852 | 397 | Remove the {\it mask} from the list of allowed masks for |
ac7f0167 VZ |
398 | \helpref{wxLogTrace}{wxlogtrace}. |
399 | ||
400 | See also: \helpref{AddTraceMask}{wxlogaddtracemask} | |
401 | ||
0290184d VZ |
402 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogBuffer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
403 | ||
404 | \section{\class{wxLogBuffer}}\label{wxlogbuffer} | |
405 | ||
406 | wxLogBuffer is a very simple implementation of log sink which simply collects | |
407 | all the logged messages in a string (except the debug messages which are output | |
408 | in the usual way immediately as we're presumably not interested in collecting | |
409 | them for later). The messages from different log function calls are separated | |
410 | by the new lines. | |
411 | ||
412 | All the messages collected so far can be shown to the user (and the current | |
413 | buffer cleared) by calling the overloaded \helpref{Flush()}{wxlogbufferflush} | |
414 | method. | |
415 | ||
416 | \wxheading{Derived from} | |
417 | ||
418 | \helpref{wxLog}{wxlog} | |
419 | ||
420 | \wxheading{Include files} | |
421 | ||
422 | <wx/log.h> | |
423 | ||
424 | \wxheading{Library} | |
425 | ||
426 | \helpref{wxBase}{librarieslist} | |
427 | ||
428 | \latexignore{\rtfignore{\wxheading{Members}}} | |
429 | ||
430 | \membersection{wxLogBuffer::GetBuffer}\label{wxlogbuffergetbuffer} | |
431 | ||
432 | \func{const wxString\& }{GetBuffer}{\void} | |
433 | ||
434 | Returns the current buffer contains. Messages from different log function calls | |
435 | are separated with the new lines in the buffer. | |
436 | ||
437 | The buffer can be cleared by \helpref{Flush()}{wxlogbufferflush} which will | |
438 | also show the current contents to the user. | |
439 | ||
440 | ||
441 | \membersection{wxLogBuffer::Flush}\label{wxlogbufferflush} | |
442 | ||
443 | \func{virtual void}{Flush}{\void} | |
444 | ||
445 | Shows all the messages collected so far to the user (using a message box in the | |
446 | GUI applications or by printing them out to the console in text mode) and | |
447 | clears the internal buffer. | |
448 | ||
449 | ||
4a20e756 VZ |
450 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogChain %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
451 | ||
452 | \section{\class{wxLogChain}}\label{wxlogchain} | |
453 | ||
454 | This simple class allows to chain log sinks, that is to install a new sink but | |
edc73852 | 455 | keep passing log messages to the old one instead of replacing it completely as |
4a20e756 VZ |
456 | \helpref{SetActiveTarget}{wxlogsetactivetarget} does. |
457 | ||
458 | It is especially useful when you want to divert the logs somewhere (for | |
459 | example to a file or a log window) but also keep showing the error messages | |
5638d705 | 460 | using the standard dialogs as \helpref{wxLogGui}{wxlogoverview} does by default. |
4a20e756 VZ |
461 | |
462 | Example of usage: | |
463 | ||
464 | \begin{verbatim} | |
465 | wxLogChain *logChain = new wxLogChain(new wxLogStderr); | |
466 | ||
467 | // all the log messages are sent to stderr and also processed as usually | |
468 | ... | |
469 | ||
2b5f62a0 VZ |
470 | // don't delete logChain directly as this would leave a dangling |
471 | // pointer as active log target, use SetActiveTarget() instead | |
472 | delete wxLog::SetActiveTarget(...something else or NULL...); | |
4a20e756 VZ |
473 | |
474 | \end{verbatim} | |
475 | ||
476 | \wxheading{Derived from} | |
477 | ||
478 | \helpref{wxLog}{wxlog} | |
479 | ||
480 | \wxheading{Include files} | |
481 | ||
482 | <wx/log.h> | |
483 | ||
a7af285d VZ |
484 | \wxheading{Library} |
485 | ||
486 | \helpref{wxBase}{librarieslist} | |
487 | ||
4a20e756 VZ |
488 | \latexignore{\rtfignore{\wxheading{Members}}} |
489 | ||
dcbd177f | 490 | \membersection{wxLogChain::wxLogChain}\label{wxlogchainctor} |
4a20e756 VZ |
491 | |
492 | \func{}{wxLogChain}{\param{wxLog *}{logger}} | |
493 | ||
494 | Sets the specified {\tt logger} (which may be {\tt NULL}) as the default log | |
495 | target but the log messages are also passed to the previous log target if any. | |
496 | ||
dcbd177f | 497 | \membersection{wxLogChain::\destruct{wxLogChain}}\label{wxlogchaindtor} |
4a20e756 VZ |
498 | |
499 | \func{}{\destruct{wxLogChain}}{\void} | |
500 | ||
501 | Destroys the previous log target. | |
502 | ||
47fe7ff3 JS |
503 | \membersection{wxLogChain::DetachOldLog}\label{wxlogchaindetacholdlog} |
504 | ||
505 | \func{void}{DetachOldLog}{\void} | |
506 | ||
507 | Detaches the old log target so it won't be destroyed when the wxLogChain object | |
508 | is destroyed. | |
509 | ||
4a20e756 VZ |
510 | \membersection{wxLogChain::GetOldLog}\label{wxlogchaingetoldlog} |
511 | ||
512 | \constfunc{wxLog *}{GetOldLog}{\void} | |
513 | ||
514 | Returns the pointer to the previously active log target (which may be {\tt | |
515 | NULL}). | |
516 | ||
517 | \membersection{wxLogChain::IsPassingMessages}\label{wxlogchainispassingmessages} | |
518 | ||
519 | \constfunc{bool}{IsPassingMessages}{\void} | |
520 | ||
cc81d32f VS |
521 | Returns {\tt true} if the messages are passed to the previously active log |
522 | target (default) or {\tt false} if \helpref{PassMessages}{wxlogchainpassmessages} | |
4a20e756 VZ |
523 | had been called. |
524 | ||
525 | \membersection{wxLogChain::PassMessages}\label{wxlogchainpassmessages} | |
526 | ||
527 | \func{void}{PassMessages}{\param{bool }{passMessages}} | |
528 | ||
529 | By default, the log messages are passed to the previously active log target. | |
cc81d32f | 530 | Calling this function with {\tt false} parameter disables this behaviour |
4a20e756 VZ |
531 | (presumably temporarily, as you shouldn't use wxLogChain at all otherwise) and |
532 | it can be reenabled by calling it again with {\it passMessages} set to {\tt | |
cc81d32f | 533 | true}. |
4a20e756 VZ |
534 | |
535 | \membersection{wxLogChain::SetLog}\label{wxlogchainsetlog} | |
536 | ||
537 | \func{void}{SetLog}{\param{wxLog *}{logger}} | |
538 | ||
539 | Sets another log target to use (may be {\tt NULL}). The log target specified | |
dcbd177f | 540 | in the \helpref{constructor}{wxlogchainctor} or in a previous call to |
4a20e756 VZ |
541 | this function is deleted. |
542 | ||
543 | This doesn't change the old log target value (the one the messages are | |
544 | forwarded to) which still remains the same as was active when wxLogChain | |
545 | object was created. | |
546 | ||
a826c315 VZ |
547 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogGui %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
548 | ||
549 | \section{\class{wxLogGui}}\label{wxloggui} | |
550 | ||
fc2171bd | 551 | This is the default log target for the GUI wxWidgets applications. It is passed |
a826c315 | 552 | to \helpref{wxLog::SetActiveTarget}{wxlogsetactivetarget} at the program |
fc2171bd | 553 | startup and is deleted by wxWidgets during the program shut down. |
a826c315 VZ |
554 | |
555 | \wxheading{Derived from} | |
556 | ||
557 | \helpref{wxLog}{wxlog} | |
558 | ||
559 | \wxheading{Include files} | |
560 | ||
561 | <wx/log.h> | |
562 | ||
563 | \latexignore{\rtfignore{\wxheading{Members}}} | |
564 | ||
dcbd177f | 565 | \membersection{wxLogGui::wxLogGui}\label{wxlogguictor} |
a826c315 VZ |
566 | |
567 | \func{}{wxLogGui}{\void} | |
568 | ||
569 | Default constructor. | |
570 | ||
571 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogNull %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
572 | ||
573 | \section{\class{wxLogNull}}\label{wxlognull} | |
574 | ||
575 | This class allows to temporarily suspend logging. All calls to the log | |
576 | functions during the life time of an object of this class are just ignored. | |
577 | ||
fc2171bd | 578 | In particular, it can be used to suppress the log messages given by wxWidgets |
a826c315 VZ |
579 | itself but it should be noted that it is rarely the best way to cope with this |
580 | problem as {\bf all} log messages are suppressed, even if they indicate a | |
581 | completely different error than the one the programmer wanted to suppress. | |
582 | ||
583 | For instance, the example of the overview: | |
584 | ||
585 | {\small | |
586 | \begin{verbatim} | |
587 | wxFile file; | |
588 | ||
589 | // wxFile.Open() normally complains if file can't be opened, we don't want it | |
590 | { | |
591 | wxLogNull logNo; | |
592 | if ( !file.Open("bar") ) | |
593 | ... process error ourselves ... | |
594 | } // ~wxLogNull called, old log sink restored | |
595 | ||
596 | wxLogMessage("..."); // ok | |
597 | \end{verbatim} | |
d2c2afc9 | 598 | }% |
a826c315 VZ |
599 | |
600 | would be better written as: | |
601 | ||
602 | {\small | |
603 | \begin{verbatim} | |
604 | wxFile file; | |
605 | ||
606 | // don't try to open file if it doesn't exist, we are prepared to deal with | |
607 | // this ourselves - but all other errors are not expected | |
608 | if ( wxFile::Exists("bar") ) | |
609 | { | |
610 | // gives an error message if the file couldn't be opened | |
611 | file.Open("bar"); | |
612 | } | |
613 | else | |
614 | { | |
615 | ... | |
616 | } | |
617 | \end{verbatim} | |
d2c2afc9 | 618 | }% |
a826c315 VZ |
619 | |
620 | \wxheading{Derived from} | |
621 | ||
622 | \helpref{wxLog}{wxlog} | |
623 | ||
624 | \wxheading{Include files} | |
625 | ||
626 | <wx/log.h> | |
627 | ||
a7af285d VZ |
628 | \wxheading{Library} |
629 | ||
630 | \helpref{wxBase}{librarieslist} | |
631 | ||
a826c315 VZ |
632 | \latexignore{\rtfignore{\wxheading{Members}}} |
633 | ||
dcbd177f | 634 | \membersection{wxLogNull::wxLogNull}\label{wxlognullctor} |
a826c315 VZ |
635 | |
636 | \func{}{wxLogNull}{\void} | |
637 | ||
638 | Suspends logging. | |
639 | ||
dcbd177f | 640 | \membersection{wxLogNull::\destruct{wxLogNull}}\label{wxlognulldtor} |
a826c315 VZ |
641 | |
642 | Resumes logging. | |
643 | ||
47fe7ff3 | 644 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f3845e88 | 645 | |
47fe7ff3 | 646 | \section{\class{wxLogInterposer}}\label{wxloginterposer} |
f3845e88 VZ |
647 | |
648 | A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the | |
47fe7ff3 | 649 | new log target. It forwards log messages to the previously installed one in addition to |
f3845e88 VZ |
650 | processing them itself. |
651 | ||
652 | Unlike \helpref{wxLogChain}{wxlogchain} which is usually used directly as is, | |
edc73852 | 653 | this class must be derived from to implement \helpref{DoLog}{wxlogdolog} |
f3845e88 VZ |
654 | and/or \helpref{DoLogString}{wxlogdologstring} methods. |
655 | ||
47fe7ff3 JS |
656 | wxLogInterposer destroys the previous log target in its destructor. If you |
657 | don't want this to happen, use wxLogInterposerTemp instead. | |
658 | ||
659 | \wxheading{Derived from} | |
660 | ||
7376079d VZ |
661 | \helpref{wxLogChain}{wxlogchain}\\ |
662 | \helpref{wxLog}{wxlog} | |
47fe7ff3 JS |
663 | |
664 | \wxheading{Include files} | |
665 | ||
666 | <wx/log.h> | |
667 | ||
a7af285d VZ |
668 | \wxheading{Library} |
669 | ||
670 | \helpref{wxBase}{librarieslist} | |
671 | ||
47fe7ff3 JS |
672 | \latexignore{\rtfignore{\wxheading{Members}}} |
673 | ||
674 | \membersection{wxLogInterposer::wxLogInterposer}\label{wxloginterposerctor} | |
675 | ||
676 | The default constructor installs this object as the current active log target. | |
677 | ||
678 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposerTemp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
679 | ||
680 | \section{\class{wxLogInterposerTemp}}\label{wxloginterposertemp} | |
681 | ||
682 | A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the | |
683 | new log target. It forwards log messages to the previously installed one in addition to | |
684 | processing them itself. Unlike \helpref{wxLogInterposer}{wxloginterposer}, it doesn't | |
685 | delete the old target which means it can be used to temporarily redirect log output. | |
686 | ||
687 | As per wxLogInterposer, this class must be derived from to implement \helpref{DoLog}{wxlogdolog} | |
688 | and/or \helpref{DoLogString}{wxlogdologstring} methods. | |
689 | ||
f3845e88 VZ |
690 | \wxheading{Derived from} |
691 | ||
7376079d VZ |
692 | \helpref{wxLogChain}{wxlogchain}\\ |
693 | \helpref{wxLog}{wxlog} | |
f3845e88 VZ |
694 | |
695 | \wxheading{Include files} | |
696 | ||
697 | <wx/log.h> | |
698 | ||
a7af285d VZ |
699 | \wxheading{Library} |
700 | ||
701 | \helpref{wxBase}{librarieslist} | |
702 | ||
f3845e88 VZ |
703 | \latexignore{\rtfignore{\wxheading{Members}}} |
704 | ||
47fe7ff3 | 705 | \membersection{wxLogInterposerTemp::wxLogInterposerTemp}\label{wxloginterposertempctor} |
f3845e88 | 706 | |
47fe7ff3 | 707 | The default constructor installs this object as the current active log target. |
f3845e88 | 708 | |
a826c315 VZ |
709 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStderr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
710 | ||
711 | \section{\class{wxLogStderr}}\label{wxlogstderr} | |
712 | ||
713 | This class can be used to redirect the log messages to a C file stream (not to | |
714 | be confused with C++ streams). It is the default log target for the non-GUI | |
fc2171bd | 715 | wxWidgets applications which send all the output to {\tt stderr}. |
a826c315 VZ |
716 | |
717 | \wxheading{Derived from} | |
718 | ||
719 | \helpref{wxLog}{wxlog} | |
720 | ||
721 | \wxheading{Include files} | |
722 | ||
723 | <wx/log.h> | |
724 | ||
a7af285d VZ |
725 | \wxheading{Library} |
726 | ||
727 | \helpref{wxBase}{librarieslist} | |
728 | ||
a826c315 VZ |
729 | \wxheading{See also} |
730 | ||
731 | \helpref{wxLogStream}{wxlogstream} | |
732 | ||
733 | \latexignore{\rtfignore{\wxheading{Members}}} | |
734 | ||
dcbd177f | 735 | \membersection{wxLogStderr::wxLogStderr}\label{wxlogstderrctor} |
a826c315 VZ |
736 | |
737 | \func{}{wxLogStderr}{\param{FILE }{*fp = NULL}} | |
738 | ||
edc73852 | 739 | Constructs a log target which sends all the log messages to the given |
a826c315 VZ |
740 | {\tt FILE}. If it is {\tt NULL}, the messages are sent to {\tt stderr}. |
741 | ||
742 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStream %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
743 | ||
744 | \section{\class{wxLogStream}}\label{wxlogstream} | |
745 | ||
746 | This class can be used to redirect the log messages to a C++ stream. | |
747 | ||
fc2171bd | 748 | Please note that this class is only available if wxWidgets was compiled with |
a826c315 VZ |
749 | the standard iostream library support ({\tt wxUSE\_STD\_IOSTREAM} must be on). |
750 | ||
751 | \wxheading{Derived from} | |
752 | ||
753 | \helpref{wxLog}{wxlog} | |
754 | ||
755 | \wxheading{Include files} | |
756 | ||
757 | <wx/log.h> | |
758 | ||
a7af285d VZ |
759 | \wxheading{Library} |
760 | ||
761 | \helpref{wxBase}{librarieslist} | |
762 | ||
a826c315 VZ |
763 | \wxheading{See also} |
764 | ||
765 | \helpref{wxLogStderr}{wxlogstderr},\\ | |
766 | \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} | |
767 | ||
768 | \latexignore{\rtfignore{\wxheading{Members}}} | |
769 | ||
dcbd177f | 770 | \membersection{wxLogStream::wxLogStream}\label{wxlogstreamctor} |
a826c315 VZ |
771 | |
772 | \func{}{wxLogStream}{\param{std::ostream }{*ostr = NULL}} | |
773 | ||
edc73852 | 774 | Constructs a log target which sends all the log messages to the given |
a826c315 VZ |
775 | output stream. If it is {\tt NULL}, the messages are sent to {\tt cerr}. |
776 | ||
777 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
778 | ||
779 | \section{\class{wxLogTextCtrl}}\label{wxlogtextctrl} | |
780 | ||
781 | Using these target all the log messages can be redirected to a text control. | |
782 | The text control must have been created with {\tt wxTE\_MULTILINE} style by the | |
783 | caller previously. | |
784 | ||
785 | \wxheading{Derived from} | |
786 | ||
787 | \helpref{wxLog}{wxlog} | |
788 | ||
789 | \wxheading{Include files} | |
790 | ||
791 | <wx/log.h> | |
792 | ||
793 | \wxheading{See also} | |
794 | ||
a0d43d79 | 795 | \helpref{wxTextCtrl}{wxtextctrl},\\ |
a826c315 VZ |
796 | \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} |
797 | ||
798 | \latexignore{\rtfignore{\wxheading{Members}}} | |
799 | ||
dcbd177f | 800 | \membersection{wxLogTextCtrl::wxLogTextCtrl}\label{wxlogtextctrlctor} |
a826c315 VZ |
801 | |
802 | \func{}{wxLogTextCtrl}{\param{wxTextCtrl }{*textctrl}} | |
803 | ||
804 | Constructs a log target which sends all the log messages to the given text | |
805 | control. The {\it textctrl} parameter cannot be {\tt NULL}. | |
806 | ||
807 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogWindow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
808 | ||
809 | \section{\class{wxLogWindow}}\label{wxlogwindow} | |
810 | ||
811 | This class represents a background log window: to be precise, it collects all | |
812 | log messages in the log frame which it manages but also passes them on to the | |
813 | log target which was active at the moment of its creation. This allows, for | |
814 | example, to show all the log messages in a frame but still continue to process | |
815 | them normally by showing the standard log dialog. | |
816 | ||
817 | \wxheading{Derived from} | |
818 | ||
7376079d VZ |
819 | \helpref{wxLogInterposer}{wxloginterposer}\\ |
820 | \helpref{wxLogChain}{wxlogchain}\\ | |
821 | \helpref{wxLog}{wxlog} | |
a826c315 VZ |
822 | |
823 | \wxheading{Include files} | |
824 | ||
825 | <wx/log.h> | |
826 | ||
827 | \wxheading{See also} | |
828 | ||
829 | \helpref{wxLogTextCtrl}{wxlogtextctrl} | |
830 | ||
831 | \latexignore{\rtfignore{\wxheading{Members}}} | |
832 | ||
dcbd177f | 833 | \membersection{wxLogWindow::wxLogWindow}\label{wxlogwindowctor} |
a826c315 | 834 | |
cc81d32f | 835 | \func{}{wxLogWindow}{\param{wxFrame }{*parent}, \param{const wxChar }{*title}, \param{bool }{show = {\tt true}}, \param{bool }{passToOld = {\tt true}}} |
a826c315 VZ |
836 | |
837 | Creates the log frame window and starts collecting the messages in it. | |
838 | ||
839 | \wxheading{Parameters} | |
840 | ||
841 | \docparam{parent}{The parent window for the log frame, may be {\tt NULL}} | |
842 | ||
843 | \docparam{title}{The title for the log frame} | |
844 | ||
cc81d32f | 845 | \docparam{show}{{\tt true} to show the frame initially (default), otherwise |
a826c315 VZ |
846 | \helpref{wxLogWindow::Show}{wxlogwindowshow} must be called later.} |
847 | ||
cc81d32f VS |
848 | \docparam{passToOld}{{\tt true} to process the log messages normally in addition to |
849 | logging them in the log frame (default), {\tt false} to only log them in the | |
a826c315 VZ |
850 | log frame.} |
851 | ||
852 | \membersection{wxLogWindow::Show}\label{wxlogwindowshow} | |
853 | ||
cc81d32f | 854 | \func{void}{Show}{\param{bool }{show = {\tt true}}} |
a826c315 VZ |
855 | |
856 | Shows or hides the frame. | |
857 | ||
dcbd177f | 858 | \membersection{wxLogWindow::GetFrame}\label{wxlogwindowgetframe} |
a826c315 VZ |
859 | |
860 | \constfunc{wxFrame *}{GetFrame}{\void} | |
861 | ||
862 | Returns the associated log frame window. This may be used to position or resize | |
863 | it but use \helpref{wxLogWindow::Show}{wxlogwindowshow} to show or hide it. | |
864 | ||
dcbd177f | 865 | \membersection{wxLogWindow::OnFrameCreate}\label{wxlogwindowonframecreate} |
a826c315 VZ |
866 | |
867 | \func{virtual void}{OnFrameCreate}{\param{wxFrame }{*frame}} | |
868 | ||
869 | Called immediately after the log frame creation allowing for | |
870 | any extra initializations. | |
871 | ||
872 | \membersection{wxLogWindow::OnFrameClose}\label{wxlogwindowonframeclose} | |
873 | ||
5ac9433d | 874 | \func{virtual bool}{OnFrameClose}{\param{wxFrame }{*frame}} |
a826c315 VZ |
875 | |
876 | Called if the user closes the window interactively, will not be | |
877 | called if it is destroyed for another reason (such as when program | |
878 | exits). | |
879 | ||
cc81d32f | 880 | Return {\tt true} from here to allow the frame to close, {\tt false} to |
a826c315 VZ |
881 | prevent this from happening. |
882 | ||
883 | \wxheading{See also} | |
884 | ||
885 | \helpref{wxLogWindow::OnFrameDelete}{wxlogwindowonframedelete} | |
886 | ||
887 | \membersection{wxLogWindow::OnFrameDelete}\label{wxlogwindowonframedelete} | |
888 | ||
889 | \func{virtual void}{OnFrameDelete}{\param{wxFrame }{*frame}} | |
890 | ||
891 | Called right before the log frame is going to be deleted: will | |
892 | always be called unlike \helpref{OnFrameClose()}{wxlogwindowonframeclose}. | |
893 |