1 \section{\class{wxLog
}}\label{wxlog
}
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.
12 Otherwise, it is completely hidden behind the
{\it wxLogXXX()
} functions and
13 you may not even know about its existence.
15 See
\helpref{log overview
}{wxlogoverview
} for the descriptions of wxWindows
18 \wxheading{Derived from
}
22 \wxheading{Include files
}
26 \latexignore{\rtfignore{\wxheading{Function groups
}}}
28 \membersection{Static functions
}
30 The functions in this section work with and manipulate the active log target.
31 The
{\it OnLog()
} is called by the
{\it wxLogXXX()
} functions and invokes the
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,
34 \helpref{DontCreateOnDemand()
}{wxlogdontcreateondemand
}
35 disables the automatic creation of a standard log target
36 if none actually exists. It is only useful when the application is terminating
37 and shouldn't be used in other situations because it may easily lead to a loss
40 \helpref{OnLog
}{wxlogonlog
}\\
41 \helpref{GetActiveTarget
}{wxloggetactivetarget
}\\
42 \helpref{SetActiveTarget
}{wxlogsetactivetarget
}\\
43 \helpref{DontCreateOnDemand
}{wxlogdontcreateondemand
}
45 \membersection{Message buffering
}
47 Some of wxLog implementations, most notably the standard
48 wxLogGui class, buffer the messages (for example, to avoid
49 showing the user a zillion of modal message boxes one after another - which
50 would be really annoying).
{\it Flush()
} shows them all and clears the buffer
51 contents. Although this function doesn't do anything if the buffer is already
52 empty,
{\it HasPendingMessages()
} is also provided which allows to explicitly
55 \helpref{Flush
}{wxlogflush
}\\
56 \helpref{FlushActive
}{wxlogflushactive
}\\
57 \helpref{HasPendingMessages
}{haspendingmessages
}
59 \membersection{Customization
}\label{wxlogcustomization
}
61 The functions below allow some limited customization of wxLog behaviour
62 without writing a new log target class (which, aside of being a matter of
63 several minutes, allows you to do anything you want).
65 The verbose messages are the trace messages which are not disabled in the
66 release mode and are generated by
\helpref{wxLogVerbose
}{wxlogverbose
}. They
67 are not normally shown to the user because they present little interest, but
68 may be activated, for example, in order to help the user find some program
71 As for the (real) trace messages, their handling depends on the settings of
72 the (application global)
{\it trace mask
}. There are two ways to specify it:
73 either by using
\helpref{SetTraceMask
}{wxlogsettracemask
} and
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.
78 The difference between bit-wise and string trace masks is that a message using
79 integer trace mask will only be logged if all bits of the mask are set in the
80 current mask while a message using string mask will be logged simply if the
81 mask had been added before to the list of allowed ones.
86 // wxTraceOleCalls is one of standard bit masks
87 wxLogTrace(wxTraceRefCount | wxTraceOleCalls, "Active object ref count:
%d", nRef);
89 will do something only if the current trace mask contains both
90 {\tt wxTraceRefCount
} and
{\tt wxTraceOle
}, but
93 // wxTRACE_OleCalls is one of standard string masks
94 wxLogTrace(wxTRACE_OleCalls, "IFoo::Bar() called");
97 will log the message if it was preceded by
100 wxLog::AddTraceMask(wxTRACE_OleCalls);
103 Using string masks is simpler and allows to easily add custom ones, so this is
104 the preferred way of working with trace messages. The integer trace mask is
105 kept for compatibility and for additional (but very rarely needed) flexibility
108 The standard trace masks are given in
\helpref{wxLogTrace
}{wxlogtrace
}
111 Finally, the
{\it wxLog::DoLog()
} function automatically prepends a time stamp
112 to all the messages. The format of the time stamp may be changed: it can be
113 any string with \% specificators fully described in the documentation of the
114 standard
{\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
117 format disables timestamping of the messages completely.
119 {\bf NB:
} Timestamping is disabled for Visual C++ users in debug builds by
120 default because otherwise it would be impossible to directly go to the line
121 from which the log message was generated by simply clicking in the debugger
122 window on the corresponding error message. If you wish to enable it, please use
123 \helpref{SetTimestamp
}{wxlogsettimestamp
} explicitly.
125 \helpref{AddTraceMask
}{wxlogaddtracemask
}\\
126 \helpref{RemoveTraceMask
}{wxlogremovetracemask
}\\
127 \helpref{ClearTraceMasks
}{wxlogcleartracemasks
}\\
128 \helpref{IsAllowedTraceMask
}{wxlogisallowedtracemask
}\\
129 \helpref{SetVerbose
}{wxlogsetverbose
}\\
130 \helpref{GetVerbose
}{wxloggetverbose
}\\
131 \helpref{SetTimestamp
}{wxlogsettimestamp
}\\
132 \helpref{GetTimestamp
}{wxloggettimestamp
}\\
133 \helpref{SetTraceMask
}{wxlogsettracemask
}\\
134 \helpref{GetTraceMask
}{wxloggettracemask
}
136 %%%%% MEMBERS HERE %%%%%
137 \helponly{\insertatlevel{2}{
143 \membersection{wxLog::AddTraceMask
}\label{wxlogaddtracemask
}
145 \func{static void
}{AddTraceMask
}{\param{const wxString\&
}{mask
}}
147 Add the
{\it mask
} to the list of allowed masks for
148 \helpref{wxLogTrace
}{wxlogtrace
}.
150 See also:
\helpref{RemoveTraceMask
}{wxlogremovetracemask
}
152 \membersection{wxLog::ClearTraceMasks
}\label{wxlogcleartracemasks
}
154 \func{static void
}{ClearTraceMasks
}{\void}
156 Removes all trace masks previously set with
157 \helpref{AddTraceMask
}{wxlogaddtracemask
}.
159 See also:
\helpref{RemoveTraceMask
}{wxlogremovetracemask
}
161 \membersection{wxLog::OnLog
}\label{wxlogonlog
}
163 \func{static void
}{OnLog
}{\param{wxLogLevel
}{ level
},
\param{const char *
}{ message
}}
165 Forwards the message at specified level to the
{\it DoLog()
} function of the
166 active log target if there is any, does nothing otherwise.
168 \membersection{wxLog::GetActiveTarget
}\label{wxloggetactivetarget
}
170 \func{static wxLog *
}{GetActiveTarget
}{\void}
172 Returns the pointer to the active log target (may be NULL).
174 \membersection{wxLog::SetActiveTarget
}\label{wxlogsetactivetarget
}
176 \func{static wxLog *
}{SetActiveTarget
}{\param{wxLog *
}{ logtarget
}}
178 Sets the specified log target as the active one. Returns the pointer to the
179 previous active log target (may be NULL).
181 \membersection{wxLog::DontCreateOnDemand
}\label{wxlogdontcreateondemand
}
183 \func{static void
}{DontCreateOnDemand
}{\void}
185 Instructs wxLog to not create new log targets on the fly if there is none
186 currently. (Almost) for internal use only: it is supposed to be called by the
187 application shutdown code.
189 Note that this function also calls
190 \helpref{ClearTraceMasks
}{wxlogcleartracemasks
}.
192 \membersection{wxLog::Flush
}\label{wxlogflush
}
194 \func{virtual void
}{Flush
}{\void}
196 Shows all the messages currently in buffer and clears it. If the buffer
197 is already empty, nothing happens.
199 \membersection{wxLog::FlushActive
}\label{wxlogflushactive
}
201 \func{static void
}{FlushActive
}{\void}
203 Flushes the current log target if any, does nothing if there is none.
207 \helpref{Flush
}{wxlogflush
}
209 \membersection{wxLog::HasPendingMessages
}\label{haspendingmessages
}
211 \constfunc{bool
}{HasPendingMessages
}{\void}
213 Returns true if there are any messages in the buffer (not yet shown to the
214 user). (Almost) for internal use only.
216 \membersection{wxLog::SetVerbose
}\label{wxlogsetverbose
}
218 \func{void
}{SetVerbose
}{\param{bool
}{ verbose = TRUE
}}
220 Activates or desactivates verbose mode in which the verbose messages are
221 logged as the normal ones instead of being silently dropped.
223 \membersection{wxLog::GetVerbose
}\label{wxloggetverbose
}
225 \constfunc{bool
}{GetVerbose
}{\void}
227 Returns whether the verbose mode is currently active.
229 \membersection{wxLog::SetTimestamp
}\label{wxlogsettimestamp
}
231 \func{void
}{SetTimestamp
}{\param{const char *
}{ format
}}
233 Sets the timestamp format prepended by the default log targets to all
234 messages. The string may contain any normal characters as well as \%
235 prefixed format specificators, see
{\it strftime()
} manual for details.
236 Passing a NULL value (not empty string) to this function disables message timestamping.
238 \membersection{wxLog::GetTimestamp
}\label{wxloggettimestamp
}
240 \constfunc{const char *
}{GetTimestamp
}{\void}
242 Returns the current timestamp format string.
244 \membersection{wxLog::SetTraceMask
}\label{wxlogsettracemask
}
246 \func{static void
}{SetTraceMask
}{\param{wxTraceMask
}{ mask
}}
248 Sets the trace mask, see
\helpref{Customization
}{wxlogcustomization
}
251 \membersection{wxLog::GetTraceMask
}\label{wxloggettracemask
}
253 Returns the current trace mask, see
\helpref{Customization
}{wxlogcustomization
} section
256 \membersection{wxLog::IsAllowedTraceMask
}\label{wxlogisallowedtracemask
}
258 \func{static bool
}{IsAllowedTraceMask
}{\param{const wxChar *
}{mask
}}
260 Returns TRUE if the
{\it mask
} is one of allowed masks for
261 \helpref{wxLogTrace
}{wxlogtrace
}.
263 See also:
\helpref{AddTraceMask
}{wxlogaddtracemask
},
264 \helpref{RemoveTraceMask
}{wxlogremovetracemask
}
266 \membersection{wxLog::RemoveTraceMask
}\label{wxlogremovetracemask
}
268 \func{static void
}{RemoveTraceMask
}{\param{const wxString\&
}{mask
}}
270 Remove the
{\it mask
} from the list of allowed masks for
271 \helpref{wxLogTrace
}{wxlogtrace
}.
273 See also:
\helpref{AddTraceMask
}{wxlogaddtracemask
}