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