]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/log.tex
Added EVT_GRID_EDITOR_CREATED and wxGridEditorCreatedEvent so the user
[wxWidgets.git] / docs / latex / wx / log.tex
CommitLineData
9ee2d31c
VZ
1\section{\class{wxLog}}\label{wxlog}
2
3wxLog class defines the interface for the {\it log targets} used by wxWindows
4logging functions as explained in the \helpref{wxLog overview}{wxlogoverview}.
5The only situations when you need to directly use this class is when you want
6to derive your own log target because the existing ones don't satisfy your
7needs. Another case is if you wish to customize the behaviour of the standard
8logging classes (all of which respect the wxLog settings): for example, set
9which trace messages are logged and which are not or change (or even remove
10completely) the timestamp on the messages.
11
12Otherwise, it is completely hidden behind the {\it wxLogXXX()} functions and
13you may not even know about its existence.
14
15See \helpref{log overview}{wxlogoverview} for the descriptions of wxWindows
16logging facilities.
17
18\wxheading{Derived from}
19
20No base class
21
954b8ae6
JS
22\wxheading{Include files}
23
24<wx/log.h>
25
9ee2d31c
VZ
26\latexignore{\rtfignore{\wxheading{Function groups}}}
27
28\membersection{Static functions}
29
30The functions in this section work with and manipulate the active log target.
99f09bc1 31The {\it OnLog()} is called by the {\it wxLogXXX()} functions and invokes the
9ee2d31c 32{\it DoLog()} of the active log target if any. Get/Set methods are used to
36bd6902
VZ
33install/query the current active target and, finally,
34\helpref{DontCreateOnDemand()}{wxlogdontcreateondemand}
35disables the automatic creation of a standard log target
9ee2d31c
VZ
36if none actually exists. It is only useful when the application is terminating
37and shouldn't be used in other situations because it may easily lead to a loss
38of messages.
39
40\helpref{OnLog}{wxlogonlog}\\
41\helpref{GetActiveTarget}{wxloggetactivetarget}\\
42ff6409 42\helpref{SetActiveTarget}{wxlogsetactivetarget}\\
9ee2d31c
VZ
43\helpref{DontCreateOnDemand}{wxlogdontcreateondemand}
44
45\membersection{Message buffering}
46
47Some of wxLog implementations, most notably the standard
6fb26ea3 48wxLogGui class, buffer the messages (for example, to avoid
9ee2d31c
VZ
49showing the user a zillion of modal message boxes one after another - which
50would be really annoying). {\it Flush()} shows them all and clears the buffer
51contents. Although this function doesn't do anything if the buffer is already
52empty, {\it HasPendingMessages()} is also provided which allows to explicitly
53verify it.
54
55\helpref{Flush}{wxlogflush}\\
e1ea357c 56\helpref{FlushActive}{wxlogflushactive}\\
9ee2d31c
VZ
57\helpref{HasPendingMessages}{haspendingmessages}
58
42ff6409 59\membersection{Customization}\label{wxlogcustomization}
9ee2d31c
VZ
60
61The functions below allow some limited customization of wxLog behaviour
62without writing a new log target class (which, aside of being a matter of
63several minutes, allows you to do anything you want).
64
65The verbose messages are the trace messages which are not disabled in the
fe482327
SB
66release mode and are generated by \helpref{wxLogVerbose}{wxlogverbose}. They
67are not normally shown to the user because they present little interest, but
68may be activated, for example, in order to help the user find some program
69problem.
9ee2d31c 70
ac7f0167
VZ
71As for the (real) trace messages, their handling depends on the settings of
72the (application global) {\it trace mask}. There are two ways to specify it:
fe482327 73either by using \helpref{SetTraceMask}{wxlogsettracemask} and
ac7f0167
VZ
74\helpref{GetTraceMask}{wxloggettracemask} and using
75\helpref{wxLogTrace}{wxlogtrace} which takes an integer mask or by using
76\helpref{AddTraceMask}{wxlogaddtracemask} for string trace masks.
77
78The difference between bit-wise and string trace masks is that a message using
79integer trace mask will only be logged if all bits of the mask are set in the
80current mask while a message using string mask will be logged simply if the
81mask had been added before to the list of allowed ones.
82
83For example,
fa482912 84
ac7f0167
VZ
85\begin{verbatim}
86// wxTraceOleCalls is one of standard bit masks
87wxLogTrace(wxTraceRefCount | wxTraceOleCalls, "Active object ref count: %d", nRef);
88\end{verbatim}
89will do something only if the current trace mask contains both
90{\tt wxTraceRefCount} and {\tt wxTraceOle}, but
fa482912 91
ac7f0167
VZ
92\begin{verbatim}
93// wxTRACE_OleCalls is one of standard string masks
fe482327 94wxLogTrace(wxTRACE_OleCalls, "IFoo::Bar() called");
ac7f0167 95\end{verbatim}
fa482912 96
ac7f0167 97will log the message if it was preceded by
fa482912 98
9ee2d31c 99\begin{verbatim}
ac7f0167 100wxLog::AddTraceMask(wxTRACE_OleCalls);
9ee2d31c 101\end{verbatim}
ac7f0167
VZ
102
103Using string masks is simpler and allows to easily add custom ones, so this is
104the preferred way of working with trace messages. The integer trace mask is
105kept for compatibility and for additional (but very rarely needed) flexibility
106only.
107
108The standard trace masks are given in \helpref{wxLogTrace}{wxlogtrace}
109documentation.
9ee2d31c
VZ
110
111Finally, the {\it wxLog::DoLog()} function automatically prepends a time stamp
112to all the messages. The format of the time stamp may be changed: it can be
113any string with \% specificators fully described in the documentation of the
114standard {\it strftime()} function. For example, the default format is
115"[\%d/\%b/\%y \%H:\%M:\%S] " which gives something like "[17/Sep/98 22:10:16] "
116(without quotes) for the current date. Setting an empty string as the time
117format disables timestamping of the messages completely.
118
ac7f0167
VZ
119{\bf NB:} Timestamping is disabled for Visual C++ users in debug builds by
120default because otherwise it would be impossible to directly go to the line
121from which the log message was generated by simply clicking in the debugger
122window on the corresponding error message. If you wish to enable it, please use
123\helpref{SetTimestamp}{wxlogsettimestamp} explicitly.
124
125\helpref{AddTraceMask}{wxlogaddtracemask}\\
126\helpref{RemoveTraceMask}{wxlogremovetracemask}\\
36bd6902 127\helpref{ClearTraceMasks}{wxlogcleartracemasks}\\
ac7f0167 128\helpref{IsAllowedTraceMask}{wxlogisallowedtracemask}\\
9ee2d31c
VZ
129\helpref{SetVerbose}{wxlogsetverbose}\\
130\helpref{GetVerbose}{wxloggetverbose}\\
22d6efa8
JS
131\helpref{SetTimestamp}{wxlogsettimestamp}\\
132\helpref{GetTimestamp}{wxloggettimestamp}\\
9ee2d31c
VZ
133\helpref{SetTraceMask}{wxlogsettracemask}\\
134\helpref{GetTraceMask}{wxloggettracemask}
135
136%%%%% MEMBERS HERE %%%%%
137\helponly{\insertatlevel{2}{
138
139\wxheading{Members}
140
141}}
142
ac7f0167
VZ
143\membersection{wxLog::AddTraceMask}\label{wxlogaddtracemask}
144
145\func{static void}{AddTraceMask}{\param{const wxString\& }{mask}}
146
147Add the {\it mask} to the list of allowed masks for
148\helpref{wxLogTrace}{wxlogtrace}.
149
150See also: \helpref{RemoveTraceMask}{wxlogremovetracemask}
151
36bd6902
VZ
152\membersection{wxLog::ClearTraceMasks}\label{wxlogcleartracemasks}
153
154\func{static void}{ClearTraceMasks}{\void}
155
156Removes all trace masks previously set with
157\helpref{AddTraceMask}{wxlogaddtracemask}.
158
159See also: \helpref{RemoveTraceMask}{wxlogremovetracemask}
160
9ee2d31c
VZ
161\membersection{wxLog::OnLog}\label{wxlogonlog}
162
163\func{static void}{OnLog}{\param{wxLogLevel }{ level}, \param{const char * }{ message}}
164
165Forwards the message at specified level to the {\it DoLog()} function of the
166active log target if there is any, does nothing otherwise.
167
168\membersection{wxLog::GetActiveTarget}\label{wxloggetactivetarget}
169
170\func{static wxLog *}{GetActiveTarget}{\void}
171
172Returns the pointer to the active log target (may be NULL).
173
174\membersection{wxLog::SetActiveTarget}\label{wxlogsetactivetarget}
175
176\func{static wxLog *}{SetActiveTarget}{\param{wxLog * }{ logtarget}}
177
178Sets the specified log target as the active one. Returns the pointer to the
179previous active log target (may be NULL).
180
181\membersection{wxLog::DontCreateOnDemand}\label{wxlogdontcreateondemand}
182
183\func{static void}{DontCreateOnDemand}{\void}
184
185Instructs wxLog to not create new log targets on the fly if there is none
36bd6902
VZ
186currently. (Almost) for internal use only: it is supposed to be called by the
187application shutdown code.
188
189Note that this function also calls
190\helpref{ClearTraceMasks}{wxlogcleartracemasks}.
9ee2d31c 191
42ff6409 192\membersection{wxLog::Flush}\label{wxlogflush}
9ee2d31c
VZ
193
194\func{virtual void}{Flush}{\void}
195
196Shows all the messages currently in buffer and clears it. If the buffer
197is already empty, nothing happens.
198
e1ea357c
VZ
199\membersection{wxLog::FlushActive}\label{wxlogflushactive}
200
201\func{static void}{FlushActive}{\void}
202
203Flushes the current log target if any, does nothing if there is none.
204
205See also:
206
207\helpref{Flush}{wxlogflush}
208
42ff6409 209\membersection{wxLog::HasPendingMessages}\label{haspendingmessages}
9ee2d31c
VZ
210
211\constfunc{bool}{HasPendingMessages}{\void}
212
213Returns true if there are any messages in the buffer (not yet shown to the
214user). (Almost) for internal use only.
215
42ff6409 216\membersection{wxLog::SetVerbose}\label{wxlogsetverbose}
9ee2d31c
VZ
217
218\func{void}{SetVerbose}{\param{bool }{ verbose = TRUE}}
219
220Activates or desactivates verbose mode in which the verbose messages are
221logged as the normal ones instead of being silently dropped.
222
42ff6409 223\membersection{wxLog::GetVerbose}\label{wxloggetverbose}
9ee2d31c
VZ
224
225\constfunc{bool}{GetVerbose}{\void}
226
227Returns whether the verbose mode is currently active.
228
22d6efa8 229\membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp}
9ee2d31c 230
22d6efa8 231\func{void}{SetTimestamp}{\param{const char * }{ format}}
9ee2d31c
VZ
232
233Sets the timestamp format prepended by the default log targets to all
234messages. The string may contain any normal characters as well as \%
235prefixed format specificators, see {\it strftime()} manual for details.
da4b7ffc 236Passing a NULL value (not empty string) to this function disables message timestamping.
9ee2d31c 237
22d6efa8 238\membersection{wxLog::GetTimestamp}\label{wxloggettimestamp}
9ee2d31c 239
22d6efa8 240\constfunc{const char *}{GetTimestamp}{\void}
9ee2d31c
VZ
241
242Returns the current timestamp format string.
243
42ff6409 244\membersection{wxLog::SetTraceMask}\label{wxlogsettracemask}
9ee2d31c
VZ
245
246\func{static void}{SetTraceMask}{\param{wxTraceMask }{ mask}}
247
248Sets the trace mask, see \helpref{Customization}{wxlogcustomization}
249section for details.
250
42ff6409 251\membersection{wxLog::GetTraceMask}\label{wxloggettracemask}
9ee2d31c 252
42ff6409
JS
253Returns the current trace mask, see \helpref{Customization}{wxlogcustomization} section
254for details.
62448488 255
ac7f0167
VZ
256\membersection{wxLog::IsAllowedTraceMask}\label{wxlogisallowedtracemask}
257
258\func{static bool}{IsAllowedTraceMask}{\param{const wxChar *}{mask}}
259
260Returns TRUE if the {\it mask} is one of allowed masks for
261\helpref{wxLogTrace}{wxlogtrace}.
262
263See also: \helpref{AddTraceMask}{wxlogaddtracemask},
264\helpref{RemoveTraceMask}{wxlogremovetracemask}
265
266\membersection{wxLog::RemoveTraceMask}\label{wxlogremovetracemask}
267
268\func{static void}{RemoveTraceMask}{\param{const wxString\& }{mask}}
269
270Remove the {\it mask} from the list of allowed masks for
271\helpref{wxLogTrace}{wxlogtrace}.
272
273See also: \helpref{AddTraceMask}{wxlogaddtracemask}
274