]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/log.tex
more samples are being built and samples/Makefiles uses SAMPLES_SUBDIRS
[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
VZ
32{\it DoLog()} of the active log target if any. Get/Set methods are used to
33install/query the current active target and, finally, {\it
34DontCreateOnDemand()} disables the automatic creation of a standard log target
35if none actually exists. It is only useful when the application is terminating
36and shouldn't be used in other situations because it may easily lead to a loss
37of messages.
38
39\helpref{OnLog}{wxlogonlog}\\
40\helpref{GetActiveTarget}{wxloggetactivetarget}\\
42ff6409 41\helpref{SetActiveTarget}{wxlogsetactivetarget}\\
9ee2d31c
VZ
42\helpref{DontCreateOnDemand}{wxlogdontcreateondemand}
43
44\membersection{Message buffering}
45
46Some of wxLog implementations, most notably the standard
6fb26ea3 47wxLogGui class, buffer the messages (for example, to avoid
9ee2d31c
VZ
48showing the user a zillion of modal message boxes one after another - which
49would be really annoying). {\it Flush()} shows them all and clears the buffer
50contents. Although this function doesn't do anything if the buffer is already
51empty, {\it HasPendingMessages()} is also provided which allows to explicitly
52verify it.
53
54\helpref{Flush}{wxlogflush}\\
e1ea357c 55\helpref{FlushActive}{wxlogflushactive}\\
9ee2d31c
VZ
56\helpref{HasPendingMessages}{haspendingmessages}
57
42ff6409 58\membersection{Customization}\label{wxlogcustomization}
9ee2d31c
VZ
59
60The functions below allow some limited customization of wxLog behaviour
61without writing a new log target class (which, aside of being a matter of
62several minutes, allows you to do anything you want).
63
64The verbose messages are the trace messages which are not disabled in the
65release mode and are generated by {\it wxLogVerbose()}. They are not normally
66shown to the user because they present little interest, but may be activated,
67for example, in order to help the user find some program problem.
68
69As for the (real) trace messages, they come in different kinds:
42ff6409 70
9ee2d31c
VZ
71\begin{itemize}\itemsep=0pt
72\item{wxTraceMemAlloc} for the messages about creating and deleting objects
73\item{wxTraceMessages} for tracing the windowing system messages/events
74\item{wxTraceResAlloc} for allocating and releasing the system ressources
75\item{wxTraceRefCount} for reference counting related messages
76\item{wxTraceOleCalls} for the OLE (or COM) method invocations (wxMSW only)
77\item{other} the remaining bits are free for user-defined trace levels
78\end{itemize}
79
80The trace mask is a bit mask which tells which (if any) of these trace
81messages are going to be actually logged. For the trace message to appear
99f09bc1 82somewhere, all the bits in the mask used in the call to {\it wxLogTrace()}
9ee2d31c
VZ
83function must be set in the current trace mask. For example,
84\begin{verbatim}
85wxLogTrace(wxTraceRefCount | wxTraceOle, "Active object ref count: %d", nRef);
86\end{verbatim}
87will do something only if the current trace mask contains both wxTraceRefCount
88and wxTraceOle.
89
90Finally, the {\it wxLog::DoLog()} function automatically prepends a time stamp
91to all the messages. The format of the time stamp may be changed: it can be
92any string with \% specificators fully described in the documentation of the
93standard {\it strftime()} function. For example, the default format is
94"[\%d/\%b/\%y \%H:\%M:\%S] " which gives something like "[17/Sep/98 22:10:16] "
95(without quotes) for the current date. Setting an empty string as the time
96format disables timestamping of the messages completely.
97
98\helpref{SetVerbose}{wxlogsetverbose}\\
99\helpref{GetVerbose}{wxloggetverbose}\\
22d6efa8
JS
100\helpref{SetTimestamp}{wxlogsettimestamp}\\
101\helpref{GetTimestamp}{wxloggettimestamp}\\
9ee2d31c
VZ
102\helpref{SetTraceMask}{wxlogsettracemask}\\
103\helpref{GetTraceMask}{wxloggettracemask}
104
105%%%%% MEMBERS HERE %%%%%
106\helponly{\insertatlevel{2}{
107
108\wxheading{Members}
109
110}}
111
112\membersection{wxLog::OnLog}\label{wxlogonlog}
113
114\func{static void}{OnLog}{\param{wxLogLevel }{ level}, \param{const char * }{ message}}
115
116Forwards the message at specified level to the {\it DoLog()} function of the
117active log target if there is any, does nothing otherwise.
118
119\membersection{wxLog::GetActiveTarget}\label{wxloggetactivetarget}
120
121\func{static wxLog *}{GetActiveTarget}{\void}
122
123Returns the pointer to the active log target (may be NULL).
124
125\membersection{wxLog::SetActiveTarget}\label{wxlogsetactivetarget}
126
127\func{static wxLog *}{SetActiveTarget}{\param{wxLog * }{ logtarget}}
128
129Sets the specified log target as the active one. Returns the pointer to the
130previous active log target (may be NULL).
131
132\membersection{wxLog::DontCreateOnDemand}\label{wxlogdontcreateondemand}
133
134\func{static void}{DontCreateOnDemand}{\void}
135
136Instructs wxLog to not create new log targets on the fly if there is none
137currently. (Almost) for internal use only.
138
42ff6409 139\membersection{wxLog::Flush}\label{wxlogflush}
9ee2d31c
VZ
140
141\func{virtual void}{Flush}{\void}
142
143Shows all the messages currently in buffer and clears it. If the buffer
144is already empty, nothing happens.
145
e1ea357c
VZ
146\membersection{wxLog::FlushActive}\label{wxlogflushactive}
147
148\func{static void}{FlushActive}{\void}
149
150Flushes the current log target if any, does nothing if there is none.
151
152See also:
153
154\helpref{Flush}{wxlogflush}
155
42ff6409 156\membersection{wxLog::HasPendingMessages}\label{haspendingmessages}
9ee2d31c
VZ
157
158\constfunc{bool}{HasPendingMessages}{\void}
159
160Returns true if there are any messages in the buffer (not yet shown to the
161user). (Almost) for internal use only.
162
42ff6409 163\membersection{wxLog::SetVerbose}\label{wxlogsetverbose}
9ee2d31c
VZ
164
165\func{void}{SetVerbose}{\param{bool }{ verbose = TRUE}}
166
167Activates or desactivates verbose mode in which the verbose messages are
168logged as the normal ones instead of being silently dropped.
169
42ff6409 170\membersection{wxLog::GetVerbose}\label{wxloggetverbose}
9ee2d31c
VZ
171
172\constfunc{bool}{GetVerbose}{\void}
173
174Returns whether the verbose mode is currently active.
175
22d6efa8 176\membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp}
9ee2d31c 177
22d6efa8 178\func{void}{SetTimestamp}{\param{const char * }{ format}}
9ee2d31c
VZ
179
180Sets the timestamp format prepended by the default log targets to all
181messages. The string may contain any normal characters as well as \%
182prefixed format specificators, see {\it strftime()} manual for details.
da4b7ffc 183Passing a NULL value (not empty string) to this function disables message timestamping.
9ee2d31c 184
22d6efa8 185\membersection{wxLog::GetTimestamp}\label{wxloggettimestamp}
9ee2d31c 186
22d6efa8 187\constfunc{const char *}{GetTimestamp}{\void}
9ee2d31c
VZ
188
189Returns the current timestamp format string.
190
42ff6409 191\membersection{wxLog::SetTraceMask}\label{wxlogsettracemask}
9ee2d31c
VZ
192
193\func{static void}{SetTraceMask}{\param{wxTraceMask }{ mask}}
194
195Sets the trace mask, see \helpref{Customization}{wxlogcustomization}
196section for details.
197
42ff6409 198\membersection{wxLog::GetTraceMask}\label{wxloggettracemask}
9ee2d31c 199
42ff6409
JS
200Returns the current trace mask, see \helpref{Customization}{wxlogcustomization} section
201for details.
62448488 202