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