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