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