]>
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 | ||
9ee2d31c VZ |
37 | \latexignore{\rtfignore{\wxheading{Function groups}}} |
38 | ||
615c6433 | 39 | \membersection{Global functions} |
9ee2d31c VZ |
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 | |
dcbd177f | 57 | \membersection{Logging functions}\label{loggingfunctions} |
4a20e756 VZ |
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 | 157 | \helpref{SetTraceMask}{wxlogsettracemask}\\ |
f9837791 VZ |
158 | \helpref{GetTraceMask}{wxloggettracemask}\\ |
159 | \helpref{SetRepetitionCounting}{wxlogsetrepetitioncounting}\\ | |
160 | \helpref{GetRepetitionCounting}{wxloggetrepetitioncounting} | |
9ee2d31c VZ |
161 | |
162 | %%%%% MEMBERS HERE %%%%% | |
163 | \helponly{\insertatlevel{2}{ | |
164 | ||
165 | \wxheading{Members} | |
166 | ||
167 | }} | |
168 | ||
ac7f0167 VZ |
169 | \membersection{wxLog::AddTraceMask}\label{wxlogaddtracemask} |
170 | ||
171 | \func{static void}{AddTraceMask}{\param{const wxString\& }{mask}} | |
172 | ||
edc73852 | 173 | Add the {\it mask} to the list of allowed masks for |
ac7f0167 VZ |
174 | \helpref{wxLogTrace}{wxlogtrace}. |
175 | ||
0e080be6 | 176 | \wxheading{See also} |
d2c2afc9 | 177 | |
0e080be6 RL |
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 | ||
edc73852 | 185 | Removes all trace masks previously set with |
36bd6902 VZ |
186 | \helpref{AddTraceMask}{wxlogaddtracemask}. |
187 | ||
0e080be6 | 188 | \wxheading{See also} |
d2c2afc9 | 189 | |
0e080be6 RL |
190 | \helpref{RemoveTraceMask}{wxlogremovetracemask} |
191 | ||
192 | \membersection{wxLog::GetTraceMasks}\label{wxloggettracemasks} | |
193 | ||
bf43ff9a | 194 | \func{static const wxArrayString \&}{GetTraceMasks}{\void} |
0e080be6 RL |
195 | |
196 | Returns the currently allowed list of string trace masks. | |
197 | ||
198 | \wxheading{See also} | |
d2c2afc9 | 199 | |
0e080be6 | 200 | \helpref{AddTraceMask}{wxlogaddtracemask}. |
36bd6902 | 201 | |
9ee2d31c VZ |
202 | \membersection{wxLog::OnLog}\label{wxlogonlog} |
203 | ||
5a20d2ce | 204 | \func{static void}{OnLog}{\param{wxLogLevel }{ level}, \param{const wxString\& }{ message}} |
9ee2d31c VZ |
205 | |
206 | Forwards the message at specified level to the {\it DoLog()} function of the | |
207 | active log target if there is any, does nothing otherwise. | |
208 | ||
209 | \membersection{wxLog::GetActiveTarget}\label{wxloggetactivetarget} | |
210 | ||
211 | \func{static wxLog *}{GetActiveTarget}{\void} | |
212 | ||
213 | Returns the pointer to the active log target (may be NULL). | |
214 | ||
215 | \membersection{wxLog::SetActiveTarget}\label{wxlogsetactivetarget} | |
216 | ||
217 | \func{static wxLog *}{SetActiveTarget}{\param{wxLog * }{ logtarget}} | |
218 | ||
219 | Sets the specified log target as the active one. Returns the pointer to the | |
154b6b0f | 220 | previous active log target (may be NULL). To suppress logging use a new |
77d47192 DE |
221 | instance of wxLogNull not NULL. If the active log target is set to NULL a |
222 | new default log target will be created when logging occurs. | |
9ee2d31c | 223 | |
b6b1d47f VZ |
224 | \membersection{wxLog::Suspend}\label{wxlogsuspend} |
225 | ||
226 | \func{static void}{Suspend}{\void} | |
227 | ||
228 | Suspends the logging until \helpref{Resume}{wxlogresume} is called. Note that | |
229 | the latter must be called the same number of times as the former to undo it, | |
230 | i.e. if you call Suspend() twice you must call Resume() twice as well. | |
231 | ||
232 | Note that suspending the logging means that the log sink won't be be flushed | |
233 | periodically, it doesn't have any effect if the current log target does the | |
234 | logging immediately without waiting for \helpref{Flush}{wxlogflush} to be | |
235 | called (the standard GUI log target only shows the log dialog when it is | |
236 | flushed, so Suspend() works as expected with it). | |
237 | ||
d2c2afc9 | 238 | \wxheading{See also} |
b6b1d47f VZ |
239 | |
240 | \helpref{Resume}{wxlogresume},\\ | |
241 | \helpref{wxLogNull}{wxlogoverview} | |
242 | ||
243 | \membersection{wxLog::Resume}\label{wxlogresume} | |
244 | ||
245 | \func{static void}{Resume}{\void} | |
246 | ||
edc73852 | 247 | Resumes logging previously suspended by a call to |
9148009b | 248 | \helpref{Suspend}{wxlogsuspend}. All messages logged in the meanwhile will be |
b6b1d47f VZ |
249 | flushed soon. |
250 | ||
4a20e756 VZ |
251 | \membersection{wxLog::DoLog}\label{wxlogdolog} |
252 | ||
5a20d2ce | 253 | \func{virtual void}{DoLog}{\param{wxLogLevel }{level}, \param{const wxString\& }{msg}, \param{time\_t }{timestamp}} |
4a20e756 VZ |
254 | |
255 | Called to process the message of the specified severity. {\it msg} is the text | |
256 | of the message as specified in the call of {\it wxLogXXX()} function which | |
257 | generated it and {\it timestamp} is the moment when the message was generated. | |
258 | ||
259 | The base class version prepends the timestamp to the message, adds a prefix | |
edc73852 | 260 | corresponding to the log level and then calls |
4a20e756 VZ |
261 | \helpref{DoLogString}{wxlogdologstring} with the resulting string. |
262 | ||
263 | \membersection{wxLog::DoLogString}\label{wxlogdologstring} | |
264 | ||
5a20d2ce | 265 | \func{virtual void}{DoLogString}{\param{const wxString\& }{msg}, \param{time\_t }{timestamp}} |
4a20e756 | 266 | |
fab86f26 | 267 | Called to log the specified string. The timestamp is already included in the |
4a20e756 VZ |
268 | string but still passed to this function. |
269 | ||
edc73852 | 270 | A simple implementation may just send the string to {\tt stdout} or, better, |
4a20e756 VZ |
271 | {\tt stderr}. |
272 | ||
9ee2d31c VZ |
273 | \membersection{wxLog::DontCreateOnDemand}\label{wxlogdontcreateondemand} |
274 | ||
275 | \func{static void}{DontCreateOnDemand}{\void} | |
276 | ||
277 | Instructs wxLog to not create new log targets on the fly if there is none | |
36bd6902 VZ |
278 | currently. (Almost) for internal use only: it is supposed to be called by the |
279 | application shutdown code. | |
280 | ||
edc73852 | 281 | Note that this function also calls |
36bd6902 | 282 | \helpref{ClearTraceMasks}{wxlogcleartracemasks}. |
9ee2d31c | 283 | |
42ff6409 | 284 | \membersection{wxLog::Flush}\label{wxlogflush} |
9ee2d31c VZ |
285 | |
286 | \func{virtual void}{Flush}{\void} | |
287 | ||
288 | Shows all the messages currently in buffer and clears it. If the buffer | |
289 | is already empty, nothing happens. | |
290 | ||
e1ea357c VZ |
291 | \membersection{wxLog::FlushActive}\label{wxlogflushactive} |
292 | ||
293 | \func{static void}{FlushActive}{\void} | |
294 | ||
295 | Flushes the current log target if any, does nothing if there is none. | |
296 | ||
d2c2afc9 | 297 | \wxheading{See also} |
e1ea357c VZ |
298 | |
299 | \helpref{Flush}{wxlogflush} | |
300 | ||
42ff6409 | 301 | \membersection{wxLog::SetVerbose}\label{wxlogsetverbose} |
9ee2d31c | 302 | |
cc81d32f | 303 | \func{static void}{SetVerbose}{\param{bool }{ verbose = true}} |
9ee2d31c | 304 | |
2edb0bde | 305 | Activates or deactivates verbose mode in which the verbose messages are |
9ee2d31c VZ |
306 | logged as the normal ones instead of being silently dropped. |
307 | ||
42ff6409 | 308 | \membersection{wxLog::GetVerbose}\label{wxloggetverbose} |
9ee2d31c | 309 | |
4a20e756 | 310 | \func{static bool}{GetVerbose}{\void} |
9ee2d31c VZ |
311 | |
312 | Returns whether the verbose mode is currently active. | |
313 | ||
edc73852 RD |
314 | \membersection{wxLog::SetLogLevel}\label{wxlogsetloglevel} |
315 | ||
316 | \func{static void}{SetLogLevel}{\param{wxLogLevel }{ logLevel}} | |
317 | ||
318 | Specifies that log messages with $level > logLevel$ should be ignored | |
319 | and not sent to the active log target. | |
320 | ||
321 | \membersection{wxLog::GetLogLevel}\label{wxloggetloglevel} | |
322 | ||
323 | \func{static wxLogLevel}{GetLogLevel}{\void} | |
324 | ||
325 | Returns the current log level limit. | |
326 | ||
f9837791 VZ |
327 | \membersection{wxLog::SetRepetitionCounting}\label{wxlogsetrepetitioncounting} |
328 | ||
329 | \func{static void}{SetRepetitionCounting}{\param{bool }{ repetCounting = true}} | |
330 | ||
331 | Enables logging mode in which a log message is logged once, and in case exactly | |
332 | the same message successively repeats one or more times, only the number of | |
333 | repetitions is logged. | |
334 | ||
335 | \membersection{wxLog::GetRepetitionCounting}\label{wxloggetrepetitioncounting} | |
336 | ||
337 | \func{static bool}{GetRepetitionCounting}{\void} | |
338 | ||
339 | Returns whether the repetition counting mode is enabled. | |
340 | ||
341 | ||
22d6efa8 | 342 | \membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp} |
9ee2d31c | 343 | |
7b1bf3ad | 344 | \func{static void}{SetTimestamp}{\param{const wxString\&}{ format}} |
9ee2d31c VZ |
345 | |
346 | Sets the timestamp format prepended by the default log targets to all | |
347 | messages. The string may contain any normal characters as well as \% | |
348 | prefixed format specificators, see {\it strftime()} manual for details. | |
7b1bf3ad VZ |
349 | Passing an empty string to this function disables message time stamping. |
350 | ||
351 | \membersection{wxLog::DisableTimestamp}\label{wxlogdisabletimestamp} | |
352 | ||
353 | \func{void}{SetTimestamp}{\param{const wxString\&}{ format}} | |
354 | ||
355 | Disables time stamping of the log messages. | |
356 | ||
357 | \newsince{2.9} | |
9ee2d31c | 358 | |
22d6efa8 | 359 | \membersection{wxLog::GetTimestamp}\label{wxloggettimestamp} |
9ee2d31c | 360 | |
7b1bf3ad | 361 | \func{static const wxString\&}{GetTimestamp}{\void} |
9ee2d31c VZ |
362 | |
363 | Returns the current timestamp format string. | |
364 | ||
42ff6409 | 365 | \membersection{wxLog::SetTraceMask}\label{wxlogsettracemask} |
9ee2d31c VZ |
366 | |
367 | \func{static void}{SetTraceMask}{\param{wxTraceMask }{ mask}} | |
368 | ||
369 | Sets the trace mask, see \helpref{Customization}{wxlogcustomization} | |
370 | section for details. | |
371 | ||
42ff6409 | 372 | \membersection{wxLog::GetTraceMask}\label{wxloggettracemask} |
7b1bf3ad VZ |
373 | |
374 | \func{static wxTraceMask}{GetTraceMask}{\void} | |
9ee2d31c | 375 | |
42ff6409 JS |
376 | Returns the current trace mask, see \helpref{Customization}{wxlogcustomization} section |
377 | for details. | |
62448488 | 378 | |
ac7f0167 VZ |
379 | \membersection{wxLog::IsAllowedTraceMask}\label{wxlogisallowedtracemask} |
380 | ||
5a20d2ce | 381 | \func{static bool}{IsAllowedTraceMask}{\param{const wxString\& }{mask}} |
ac7f0167 | 382 | |
cc81d32f | 383 | Returns true if the {\it mask} is one of allowed masks for |
ac7f0167 VZ |
384 | \helpref{wxLogTrace}{wxlogtrace}. |
385 | ||
edc73852 | 386 | See also: \helpref{AddTraceMask}{wxlogaddtracemask}, |
ac7f0167 VZ |
387 | \helpref{RemoveTraceMask}{wxlogremovetracemask} |
388 | ||
389 | \membersection{wxLog::RemoveTraceMask}\label{wxlogremovetracemask} | |
390 | ||
391 | \func{static void}{RemoveTraceMask}{\param{const wxString\& }{mask}} | |
392 | ||
edc73852 | 393 | Remove the {\it mask} from the list of allowed masks for |
ac7f0167 VZ |
394 | \helpref{wxLogTrace}{wxlogtrace}. |
395 | ||
396 | See also: \helpref{AddTraceMask}{wxlogaddtracemask} | |
397 | ||
4a20e756 VZ |
398 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogChain %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
399 | ||
400 | \section{\class{wxLogChain}}\label{wxlogchain} | |
401 | ||
402 | This simple class allows to chain log sinks, that is to install a new sink but | |
edc73852 | 403 | keep passing log messages to the old one instead of replacing it completely as |
4a20e756 VZ |
404 | \helpref{SetActiveTarget}{wxlogsetactivetarget} does. |
405 | ||
406 | It is especially useful when you want to divert the logs somewhere (for | |
407 | example to a file or a log window) but also keep showing the error messages | |
5638d705 | 408 | using the standard dialogs as \helpref{wxLogGui}{wxlogoverview} does by default. |
4a20e756 VZ |
409 | |
410 | Example of usage: | |
411 | ||
412 | \begin{verbatim} | |
413 | wxLogChain *logChain = new wxLogChain(new wxLogStderr); | |
414 | ||
415 | // all the log messages are sent to stderr and also processed as usually | |
416 | ... | |
417 | ||
2b5f62a0 VZ |
418 | // don't delete logChain directly as this would leave a dangling |
419 | // pointer as active log target, use SetActiveTarget() instead | |
420 | delete wxLog::SetActiveTarget(...something else or NULL...); | |
4a20e756 VZ |
421 | |
422 | \end{verbatim} | |
423 | ||
424 | \wxheading{Derived from} | |
425 | ||
426 | \helpref{wxLog}{wxlog} | |
427 | ||
428 | \wxheading{Include files} | |
429 | ||
430 | <wx/log.h> | |
431 | ||
432 | \latexignore{\rtfignore{\wxheading{Members}}} | |
433 | ||
dcbd177f | 434 | \membersection{wxLogChain::wxLogChain}\label{wxlogchainctor} |
4a20e756 VZ |
435 | |
436 | \func{}{wxLogChain}{\param{wxLog *}{logger}} | |
437 | ||
438 | Sets the specified {\tt logger} (which may be {\tt NULL}) as the default log | |
439 | target but the log messages are also passed to the previous log target if any. | |
440 | ||
dcbd177f | 441 | \membersection{wxLogChain::\destruct{wxLogChain}}\label{wxlogchaindtor} |
4a20e756 VZ |
442 | |
443 | \func{}{\destruct{wxLogChain}}{\void} | |
444 | ||
445 | Destroys the previous log target. | |
446 | ||
47fe7ff3 JS |
447 | \membersection{wxLogChain::DetachOldLog}\label{wxlogchaindetacholdlog} |
448 | ||
449 | \func{void}{DetachOldLog}{\void} | |
450 | ||
451 | Detaches the old log target so it won't be destroyed when the wxLogChain object | |
452 | is destroyed. | |
453 | ||
4a20e756 VZ |
454 | \membersection{wxLogChain::GetOldLog}\label{wxlogchaingetoldlog} |
455 | ||
456 | \constfunc{wxLog *}{GetOldLog}{\void} | |
457 | ||
458 | Returns the pointer to the previously active log target (which may be {\tt | |
459 | NULL}). | |
460 | ||
461 | \membersection{wxLogChain::IsPassingMessages}\label{wxlogchainispassingmessages} | |
462 | ||
463 | \constfunc{bool}{IsPassingMessages}{\void} | |
464 | ||
cc81d32f VS |
465 | Returns {\tt true} if the messages are passed to the previously active log |
466 | target (default) or {\tt false} if \helpref{PassMessages}{wxlogchainpassmessages} | |
4a20e756 VZ |
467 | had been called. |
468 | ||
469 | \membersection{wxLogChain::PassMessages}\label{wxlogchainpassmessages} | |
470 | ||
471 | \func{void}{PassMessages}{\param{bool }{passMessages}} | |
472 | ||
473 | By default, the log messages are passed to the previously active log target. | |
cc81d32f | 474 | Calling this function with {\tt false} parameter disables this behaviour |
4a20e756 VZ |
475 | (presumably temporarily, as you shouldn't use wxLogChain at all otherwise) and |
476 | it can be reenabled by calling it again with {\it passMessages} set to {\tt | |
cc81d32f | 477 | true}. |
4a20e756 VZ |
478 | |
479 | \membersection{wxLogChain::SetLog}\label{wxlogchainsetlog} | |
480 | ||
481 | \func{void}{SetLog}{\param{wxLog *}{logger}} | |
482 | ||
483 | Sets another log target to use (may be {\tt NULL}). The log target specified | |
dcbd177f | 484 | in the \helpref{constructor}{wxlogchainctor} or in a previous call to |
4a20e756 VZ |
485 | this function is deleted. |
486 | ||
487 | This doesn't change the old log target value (the one the messages are | |
488 | forwarded to) which still remains the same as was active when wxLogChain | |
489 | object was created. | |
490 | ||
a826c315 VZ |
491 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogGui %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
492 | ||
493 | \section{\class{wxLogGui}}\label{wxloggui} | |
494 | ||
fc2171bd | 495 | This is the default log target for the GUI wxWidgets applications. It is passed |
a826c315 | 496 | to \helpref{wxLog::SetActiveTarget}{wxlogsetactivetarget} at the program |
fc2171bd | 497 | startup and is deleted by wxWidgets during the program shut down. |
a826c315 VZ |
498 | |
499 | \wxheading{Derived from} | |
500 | ||
501 | \helpref{wxLog}{wxlog} | |
502 | ||
503 | \wxheading{Include files} | |
504 | ||
505 | <wx/log.h> | |
506 | ||
507 | \latexignore{\rtfignore{\wxheading{Members}}} | |
508 | ||
dcbd177f | 509 | \membersection{wxLogGui::wxLogGui}\label{wxlogguictor} |
a826c315 VZ |
510 | |
511 | \func{}{wxLogGui}{\void} | |
512 | ||
513 | Default constructor. | |
514 | ||
515 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogNull %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
516 | ||
517 | \section{\class{wxLogNull}}\label{wxlognull} | |
518 | ||
519 | This class allows to temporarily suspend logging. All calls to the log | |
520 | functions during the life time of an object of this class are just ignored. | |
521 | ||
fc2171bd | 522 | In particular, it can be used to suppress the log messages given by wxWidgets |
a826c315 VZ |
523 | itself but it should be noted that it is rarely the best way to cope with this |
524 | problem as {\bf all} log messages are suppressed, even if they indicate a | |
525 | completely different error than the one the programmer wanted to suppress. | |
526 | ||
527 | For instance, the example of the overview: | |
528 | ||
529 | {\small | |
530 | \begin{verbatim} | |
531 | wxFile file; | |
532 | ||
533 | // wxFile.Open() normally complains if file can't be opened, we don't want it | |
534 | { | |
535 | wxLogNull logNo; | |
536 | if ( !file.Open("bar") ) | |
537 | ... process error ourselves ... | |
538 | } // ~wxLogNull called, old log sink restored | |
539 | ||
540 | wxLogMessage("..."); // ok | |
541 | \end{verbatim} | |
d2c2afc9 | 542 | }% |
a826c315 VZ |
543 | |
544 | would be better written as: | |
545 | ||
546 | {\small | |
547 | \begin{verbatim} | |
548 | wxFile file; | |
549 | ||
550 | // don't try to open file if it doesn't exist, we are prepared to deal with | |
551 | // this ourselves - but all other errors are not expected | |
552 | if ( wxFile::Exists("bar") ) | |
553 | { | |
554 | // gives an error message if the file couldn't be opened | |
555 | file.Open("bar"); | |
556 | } | |
557 | else | |
558 | { | |
559 | ... | |
560 | } | |
561 | \end{verbatim} | |
d2c2afc9 | 562 | }% |
a826c315 VZ |
563 | |
564 | \wxheading{Derived from} | |
565 | ||
566 | \helpref{wxLog}{wxlog} | |
567 | ||
568 | \wxheading{Include files} | |
569 | ||
570 | <wx/log.h> | |
571 | ||
572 | \latexignore{\rtfignore{\wxheading{Members}}} | |
573 | ||
dcbd177f | 574 | \membersection{wxLogNull::wxLogNull}\label{wxlognullctor} |
a826c315 VZ |
575 | |
576 | \func{}{wxLogNull}{\void} | |
577 | ||
578 | Suspends logging. | |
579 | ||
dcbd177f | 580 | \membersection{wxLogNull::\destruct{wxLogNull}}\label{wxlognulldtor} |
a826c315 VZ |
581 | |
582 | Resumes logging. | |
583 | ||
47fe7ff3 | 584 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f3845e88 | 585 | |
47fe7ff3 | 586 | \section{\class{wxLogInterposer}}\label{wxloginterposer} |
f3845e88 VZ |
587 | |
588 | A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the | |
47fe7ff3 | 589 | new log target. It forwards log messages to the previously installed one in addition to |
f3845e88 VZ |
590 | processing them itself. |
591 | ||
592 | Unlike \helpref{wxLogChain}{wxlogchain} which is usually used directly as is, | |
edc73852 | 593 | this class must be derived from to implement \helpref{DoLog}{wxlogdolog} |
f3845e88 VZ |
594 | and/or \helpref{DoLogString}{wxlogdologstring} methods. |
595 | ||
47fe7ff3 JS |
596 | wxLogInterposer destroys the previous log target in its destructor. If you |
597 | don't want this to happen, use wxLogInterposerTemp instead. | |
598 | ||
599 | \wxheading{Derived from} | |
600 | ||
601 | \helpref{wxLogChain}{wxlogchain} | |
602 | ||
603 | \wxheading{Include files} | |
604 | ||
605 | <wx/log.h> | |
606 | ||
607 | \latexignore{\rtfignore{\wxheading{Members}}} | |
608 | ||
609 | \membersection{wxLogInterposer::wxLogInterposer}\label{wxloginterposerctor} | |
610 | ||
611 | The default constructor installs this object as the current active log target. | |
612 | ||
613 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposerTemp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
614 | ||
615 | \section{\class{wxLogInterposerTemp}}\label{wxloginterposertemp} | |
616 | ||
617 | A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the | |
618 | new log target. It forwards log messages to the previously installed one in addition to | |
619 | processing them itself. Unlike \helpref{wxLogInterposer}{wxloginterposer}, it doesn't | |
620 | delete the old target which means it can be used to temporarily redirect log output. | |
621 | ||
622 | As per wxLogInterposer, this class must be derived from to implement \helpref{DoLog}{wxlogdolog} | |
623 | and/or \helpref{DoLogString}{wxlogdologstring} methods. | |
624 | ||
f3845e88 VZ |
625 | \wxheading{Derived from} |
626 | ||
627 | \helpref{wxLogChain}{wxlogchain} | |
628 | ||
629 | \wxheading{Include files} | |
630 | ||
631 | <wx/log.h> | |
632 | ||
633 | \latexignore{\rtfignore{\wxheading{Members}}} | |
634 | ||
47fe7ff3 | 635 | \membersection{wxLogInterposerTemp::wxLogInterposerTemp}\label{wxloginterposertempctor} |
f3845e88 | 636 | |
47fe7ff3 | 637 | The default constructor installs this object as the current active log target. |
f3845e88 | 638 | |
a826c315 VZ |
639 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStderr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
640 | ||
641 | \section{\class{wxLogStderr}}\label{wxlogstderr} | |
642 | ||
643 | This class can be used to redirect the log messages to a C file stream (not to | |
644 | be confused with C++ streams). It is the default log target for the non-GUI | |
fc2171bd | 645 | wxWidgets applications which send all the output to {\tt stderr}. |
a826c315 VZ |
646 | |
647 | \wxheading{Derived from} | |
648 | ||
649 | \helpref{wxLog}{wxlog} | |
650 | ||
651 | \wxheading{Include files} | |
652 | ||
653 | <wx/log.h> | |
654 | ||
655 | \wxheading{See also} | |
656 | ||
657 | \helpref{wxLogStream}{wxlogstream} | |
658 | ||
659 | \latexignore{\rtfignore{\wxheading{Members}}} | |
660 | ||
dcbd177f | 661 | \membersection{wxLogStderr::wxLogStderr}\label{wxlogstderrctor} |
a826c315 VZ |
662 | |
663 | \func{}{wxLogStderr}{\param{FILE }{*fp = NULL}} | |
664 | ||
edc73852 | 665 | Constructs a log target which sends all the log messages to the given |
a826c315 VZ |
666 | {\tt FILE}. If it is {\tt NULL}, the messages are sent to {\tt stderr}. |
667 | ||
668 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStream %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
669 | ||
670 | \section{\class{wxLogStream}}\label{wxlogstream} | |
671 | ||
672 | This class can be used to redirect the log messages to a C++ stream. | |
673 | ||
fc2171bd | 674 | Please note that this class is only available if wxWidgets was compiled with |
a826c315 VZ |
675 | the standard iostream library support ({\tt wxUSE\_STD\_IOSTREAM} must be on). |
676 | ||
677 | \wxheading{Derived from} | |
678 | ||
679 | \helpref{wxLog}{wxlog} | |
680 | ||
681 | \wxheading{Include files} | |
682 | ||
683 | <wx/log.h> | |
684 | ||
685 | \wxheading{See also} | |
686 | ||
687 | \helpref{wxLogStderr}{wxlogstderr},\\ | |
688 | \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} | |
689 | ||
690 | \latexignore{\rtfignore{\wxheading{Members}}} | |
691 | ||
dcbd177f | 692 | \membersection{wxLogStream::wxLogStream}\label{wxlogstreamctor} |
a826c315 VZ |
693 | |
694 | \func{}{wxLogStream}{\param{std::ostream }{*ostr = NULL}} | |
695 | ||
edc73852 | 696 | Constructs a log target which sends all the log messages to the given |
a826c315 VZ |
697 | output stream. If it is {\tt NULL}, the messages are sent to {\tt cerr}. |
698 | ||
699 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
700 | ||
701 | \section{\class{wxLogTextCtrl}}\label{wxlogtextctrl} | |
702 | ||
703 | Using these target all the log messages can be redirected to a text control. | |
704 | The text control must have been created with {\tt wxTE\_MULTILINE} style by the | |
705 | caller previously. | |
706 | ||
707 | \wxheading{Derived from} | |
708 | ||
709 | \helpref{wxLog}{wxlog} | |
710 | ||
711 | \wxheading{Include files} | |
712 | ||
713 | <wx/log.h> | |
714 | ||
715 | \wxheading{See also} | |
716 | ||
a0d43d79 | 717 | \helpref{wxTextCtrl}{wxtextctrl},\\ |
a826c315 VZ |
718 | \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} |
719 | ||
720 | \latexignore{\rtfignore{\wxheading{Members}}} | |
721 | ||
dcbd177f | 722 | \membersection{wxLogTextCtrl::wxLogTextCtrl}\label{wxlogtextctrlctor} |
a826c315 VZ |
723 | |
724 | \func{}{wxLogTextCtrl}{\param{wxTextCtrl }{*textctrl}} | |
725 | ||
726 | Constructs a log target which sends all the log messages to the given text | |
727 | control. The {\it textctrl} parameter cannot be {\tt NULL}. | |
728 | ||
729 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogWindow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
730 | ||
731 | \section{\class{wxLogWindow}}\label{wxlogwindow} | |
732 | ||
733 | This class represents a background log window: to be precise, it collects all | |
734 | log messages in the log frame which it manages but also passes them on to the | |
735 | log target which was active at the moment of its creation. This allows, for | |
736 | example, to show all the log messages in a frame but still continue to process | |
737 | them normally by showing the standard log dialog. | |
738 | ||
739 | \wxheading{Derived from} | |
740 | ||
47fe7ff3 | 741 | \helpref{wxLogInterposer}{wxloginterposer} |
a826c315 VZ |
742 | |
743 | \wxheading{Include files} | |
744 | ||
745 | <wx/log.h> | |
746 | ||
747 | \wxheading{See also} | |
748 | ||
749 | \helpref{wxLogTextCtrl}{wxlogtextctrl} | |
750 | ||
751 | \latexignore{\rtfignore{\wxheading{Members}}} | |
752 | ||
dcbd177f | 753 | \membersection{wxLogWindow::wxLogWindow}\label{wxlogwindowctor} |
a826c315 | 754 | |
cc81d32f | 755 | \func{}{wxLogWindow}{\param{wxFrame }{*parent}, \param{const wxChar }{*title}, \param{bool }{show = {\tt true}}, \param{bool }{passToOld = {\tt true}}} |
a826c315 VZ |
756 | |
757 | Creates the log frame window and starts collecting the messages in it. | |
758 | ||
759 | \wxheading{Parameters} | |
760 | ||
761 | \docparam{parent}{The parent window for the log frame, may be {\tt NULL}} | |
762 | ||
763 | \docparam{title}{The title for the log frame} | |
764 | ||
cc81d32f | 765 | \docparam{show}{{\tt true} to show the frame initially (default), otherwise |
a826c315 VZ |
766 | \helpref{wxLogWindow::Show}{wxlogwindowshow} must be called later.} |
767 | ||
cc81d32f VS |
768 | \docparam{passToOld}{{\tt true} to process the log messages normally in addition to |
769 | logging them in the log frame (default), {\tt false} to only log them in the | |
a826c315 VZ |
770 | log frame.} |
771 | ||
772 | \membersection{wxLogWindow::Show}\label{wxlogwindowshow} | |
773 | ||
cc81d32f | 774 | \func{void}{Show}{\param{bool }{show = {\tt true}}} |
a826c315 VZ |
775 | |
776 | Shows or hides the frame. | |
777 | ||
dcbd177f | 778 | \membersection{wxLogWindow::GetFrame}\label{wxlogwindowgetframe} |
a826c315 VZ |
779 | |
780 | \constfunc{wxFrame *}{GetFrame}{\void} | |
781 | ||
782 | Returns the associated log frame window. This may be used to position or resize | |
783 | it but use \helpref{wxLogWindow::Show}{wxlogwindowshow} to show or hide it. | |
784 | ||
dcbd177f | 785 | \membersection{wxLogWindow::OnFrameCreate}\label{wxlogwindowonframecreate} |
a826c315 VZ |
786 | |
787 | \func{virtual void}{OnFrameCreate}{\param{wxFrame }{*frame}} | |
788 | ||
789 | Called immediately after the log frame creation allowing for | |
790 | any extra initializations. | |
791 | ||
792 | \membersection{wxLogWindow::OnFrameClose}\label{wxlogwindowonframeclose} | |
793 | ||
5ac9433d | 794 | \func{virtual bool}{OnFrameClose}{\param{wxFrame }{*frame}} |
a826c315 VZ |
795 | |
796 | Called if the user closes the window interactively, will not be | |
797 | called if it is destroyed for another reason (such as when program | |
798 | exits). | |
799 | ||
cc81d32f | 800 | Return {\tt true} from here to allow the frame to close, {\tt false} to |
a826c315 VZ |
801 | prevent this from happening. |
802 | ||
803 | \wxheading{See also} | |
804 | ||
805 | \helpref{wxLogWindow::OnFrameDelete}{wxlogwindowonframedelete} | |
806 | ||
807 | \membersection{wxLogWindow::OnFrameDelete}\label{wxlogwindowonframedelete} | |
808 | ||
809 | \func{virtual void}{OnFrameDelete}{\param{wxFrame }{*frame}} | |
810 | ||
811 | Called right before the log frame is going to be deleted: will | |
812 | always be called unlike \helpref{OnFrameClose()}{wxlogwindowonframeclose}. | |
813 |