1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
<HTML>
<head><title>wxLog</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxlog"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx131.htm#wxlocale"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx133.htm#wxmask"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxLog</H2>
<P>
wxLog class defines the interface for the <I>log targets</I> used by wxWindows
logging functions as explained in the <A HREF="wx282.htm#wxlogoverview">wxLog overview</A>.
The only situations when you need to directly use this class is when you want
to derive your own log target because the existing ones don't satisfy your
needs. Another case is if you wish to customize the behaviour of the standard
logging classes (all of which respect the wxLog settings): for example, set
which trace messages are logged and which are not or change (or even remove
completely) the timestamp on the messages.<P>
Otherwise, it is completely hidden behind the <I>wxLogXXX()</I> functions and
you may not even know about its existence.<P>
See <A HREF="wx282.htm#wxlogoverview">log overview</A> for the descriptions of wxWindows
logging facilities.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
No base class<P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/log.h><P>
<B><FONT COLOR="#FF0000">Function groups</FONT></B><P>
<A HREF="#topic547">Static functions</A><BR>
<A HREF="#topic548">Message buffering</A><BR>
<A HREF="#wxlogcustomization">Customization</A><BR>
<A HREF="#wxlogonlog">wxLog::OnLog</A><BR>
<A HREF="#wxloggetactivetarget">wxLog::GetActiveTarget</A><BR>
<A HREF="#wxlogsetactivetarget">wxLog::SetActiveTarget</A><BR>
<A HREF="#wxlogdontcreateondemand">wxLog::DontCreateOnDemand</A><BR>
<A HREF="#wxlogflush">wxLog::Flush</A><BR>
<A HREF="#haspendingmessages">wxLog::HasPendingMessages</A><BR>
<A HREF="#wxlogsetverbose">wxLog::SetVerbose</A><BR>
<A HREF="#wxloggetverbose">wxLog::GetVerbose</A><BR>
<A HREF="#wxlogsettimestampformat">wxLog::SetTimeStampFormat</A><BR>
<A HREF="#wxloggettimestampformat">wxLog::GetTimeStampFormat</A><BR>
<A HREF="#wxlogsettracemask">wxLog::SetTraceMask</A><BR>
<A HREF="#wxloggettracemask">wxLog::GetTraceMask</A><BR>
<P>
<HR>
<A NAME="topic547"></A>
<H3>Static functions</H3>
<P>
The functions in this section work with and manipulate the active log target.
The <I>OnLog()</I> is called by the <I>wxLogXXX()</I> functions and invokes the
<I>DoLog()</I> of the active log target if any. Get/Set methods are used to
install/query the current active target and, finally, <I>
DontCreateOnDemand()</I> disables the automatic creation of a standard log target
if none actually exists. It is only useful when the application is terminating
and shouldn't be used in other situations because it may easily lead to a loss
of messages.<P>
<A HREF="wx132.htm#wxlogonlog">OnLog</A><BR>
<A HREF="wx132.htm#wxloggetactivetarget">GetActiveTarget</A><BR>
<A HREF="wx132.htm#wxlogsetactivetarget">SetActiveTarget</A><BR>
<A HREF="wx132.htm#wxlogdontcreateondemand">DontCreateOnDemand</A><P>
<HR>
<A NAME="topic548"></A>
<H3>Message buffering</H3>
<P>
Some of wxLog implementations, most notably the standard
wxLogGui class, buffer the messages (for example, to avoid
showing the user a zillion of modal message boxes one after another - which
would be really annoying). <I>Flush()</I> shows them all and clears the buffer
contents. Although this function doesn't do anything if the buffer is already
empty, <I>HasPendingMessages()</I> is also provided which allows to explicitly
verify it.<P>
<A HREF="wx132.htm#wxlogflush">Flush</A><BR>
<A HREF="wx132.htm#haspendingmessages">HasPendingMessages</A><P>
<HR>
<A NAME="wxlogcustomization"></A>
<H3>Customization</H3>
<P>
The functions below allow some limited customization of wxLog behaviour
without writing a new log target class (which, aside of being a matter of
several minutes, allows you to do anything you want).<P>
The verbose messages are the trace messages which are not disabled in the
release mode and are generated by <I>wxLogVerbose()</I>. They are not normally
shown to the user because they present little interest, but may be activated,
for example, in order to help the user find some program problem.<P>
As for the (real) trace messages, they come in different kinds:<P>
<UL>
<LI>wxTraceMemAlloc for the messages about creating and deleting objects
<LI>wxTraceMessages for tracing the windowing system messages/events
<LI>wxTraceResAlloc for allocating and releasing the system ressources
<LI>wxTraceRefCount for reference counting related messages
<LI>wxTraceOleCalls for the OLE (or COM) method invocations (wxMSW only)
<LI>other the remaining bits are free for user-defined trace levels
</UL>
<P>
The trace mask is a bit mask which tells which (if any) of these trace
messages are going to be actually logged. For the trace message to appear
somewhere, all the bits in the mask used in the call to <I>wxLogTrace()</I>
function must be set in the current trace mask. For example,
<PRE>
wxLogTrace(wxTraceRefCount | wxTraceOle, "Active object ref count: %d", nRef);
</PRE>
will do something only if the current trace mask contains both wxTraceRefCount
and wxTraceOle.<P>
Finally, the <I>wxLog::DoLog()</I> function automatically prepends a time stamp
to all the messages. The format of the time stamp may be changed: it can be
any string with % specificators fully described in the documentation of the
standard <I>strftime()</I> function. For example, the default format is
"[%d/%b/%y %H:%M:%S] " which gives something like "[17/Sep/98 22:10:16] "
(without quotes) for the current date. Setting an empty string as the time
format disables timestamping of the messages completely.<P>
<A HREF="wx132.htm#wxlogsetverbose">SetVerbose</A><BR>
<A HREF="wx132.htm#wxloggetverbose">GetVerbose</A><BR>
<A HREF="wx132.htm#wxlogsettimestampformat">SetTimeStampFormat</A><BR>
<A HREF="wx132.htm#wxloggettimestampformat">GetTimeStampFormat</A><BR>
<A HREF="wx132.htm#wxlogsettracemask">SetTraceMask</A><BR>
<A HREF="wx132.htm#wxloggettracemask">GetTraceMask</A><P>
<P>
<HR>
<A NAME="wxlogonlog"></A>
<H3>wxLog::OnLog</H3>
<P>
<B>static void</B> <B>OnLog</B>(<B>wxLogLevel </B><I> level</I>, <B>const char * </B><I> message</I>)<P>
Forwards the message at specified level to the <I>DoLog()</I> function of the
active log target if there is any, does nothing otherwise.<P>
<HR>
<A NAME="wxloggetactivetarget"></A>
<H3>wxLog::GetActiveTarget</H3>
<P>
<B>static wxLog *</B> <B>GetActiveTarget</B>()<P>
Returns the pointer to the active log target (may be NULL).<P>
<HR>
<A NAME="wxlogsetactivetarget"></A>
<H3>wxLog::SetActiveTarget</H3>
<P>
<B>static wxLog *</B> <B>SetActiveTarget</B>(<B>wxLog * </B><I> logtarget</I>)<P>
Sets the specified log target as the active one. Returns the pointer to the
previous active log target (may be NULL).<P>
<HR>
<A NAME="wxlogdontcreateondemand"></A>
<H3>wxLog::DontCreateOnDemand</H3>
<P>
<B>static void</B> <B>DontCreateOnDemand</B>()<P>
Instructs wxLog to not create new log targets on the fly if there is none
currently. (Almost) for internal use only.<P>
<HR>
<A NAME="wxlogflush"></A>
<H3>wxLog::Flush</H3>
<P>
<B>virtual void</B> <B>Flush</B>()<P>
Shows all the messages currently in buffer and clears it. If the buffer
is already empty, nothing happens.<P>
<HR>
<A NAME="haspendingmessages"></A>
<H3>wxLog::HasPendingMessages</H3>
<P>
<B>bool</B> <B>HasPendingMessages</B>() <B>const</B><P>
Returns true if there are any messages in the buffer (not yet shown to the
user). (Almost) for internal use only.<P>
<HR>
<A NAME="wxlogsetverbose"></A>
<H3>wxLog::SetVerbose</H3>
<P>
<B>void</B> <B>SetVerbose</B>(<B>bool </B><I> verbose = TRUE</I>)<P>
Activates or desactivates verbose mode in which the verbose messages are
logged as the normal ones instead of being silently dropped.<P>
<HR>
<A NAME="wxloggetverbose"></A>
<H3>wxLog::GetVerbose</H3>
<P>
<B>bool</B> <B>GetVerbose</B>() <B>const</B><P>
Returns whether the verbose mode is currently active.<P>
<HR>
<A NAME="wxlogsettimestampformat"></A>
<H3>wxLog::SetTimeStampFormat</H3>
<P>
<B>void</B> <B>SetTimeStampFormat</B>(<B>const char * </B><I> format</I>)<P>
Sets the timestamp format prepended by the default log targets to all
messages. The string may contain any normal characters as well as %
prefixed format specificators, see <I>strftime()</I> manual for details.
Passing an empty string to this function disables message timestamping.<P>
<HR>
<A NAME="wxloggettimestampformat"></A>
<H3>wxLog::GetTimeStampFormat</H3>
<P>
<B>const char *</B> <B>GetTimeStampFormat</B>() <B>const</B><P>
Returns the current timestamp format string.<P>
<HR>
<A NAME="wxlogsettracemask"></A>
<H3>wxLog::SetTraceMask</H3>
<P>
<B>static void</B> <B>SetTraceMask</B>(<B>wxTraceMask </B><I> mask</I>)<P>
Sets the trace mask, see <A HREF="wx132.htm#wxlogcustomization">Customization</A>
section for details.<P>
<HR>
<A NAME="wxloggettracemask"></A>
<H3>wxLog::GetTraceMask</H3>
<P>
Returns the current trace mask, see <A HREF="wx132.htm#wxlogcustomization">Customization</A> section
for details.<P>
</BODY></HTML>
|