1998-09-29 20:48:01 -04:00
|
|
|
\section{\class{wxLog}}\label{wxlog}
|
|
|
|
|
|
|
|
wxLog class defines the interface for the {\it log targets} used by wxWindows
|
|
|
|
logging functions as explained in the \helpref{wxLog overview}{wxlogoverview}.
|
|
|
|
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.
|
|
|
|
|
|
|
|
Otherwise, it is completely hidden behind the {\it wxLogXXX()} functions and
|
|
|
|
you may not even know about its existence.
|
|
|
|
|
|
|
|
See \helpref{log overview}{wxlogoverview} for the descriptions of wxWindows
|
|
|
|
logging facilities.
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
No base class
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/log.h>
|
|
|
|
|
1998-09-29 20:48:01 -04:00
|
|
|
\latexignore{\rtfignore{\wxheading{Function groups}}}
|
|
|
|
|
|
|
|
\membersection{Static functions}
|
|
|
|
|
|
|
|
The functions in this section work with and manipulate the active log target.
|
1999-02-24 18:53:40 -05:00
|
|
|
The {\it OnLog()} is called by the {\it wxLogXXX()} functions and invokes the
|
1998-09-29 20:48:01 -04:00
|
|
|
{\it DoLog()} of the active log target if any. Get/Set methods are used to
|
|
|
|
install/query the current active target and, finally, {\it
|
|
|
|
DontCreateOnDemand()} 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.
|
|
|
|
|
|
|
|
\helpref{OnLog}{wxlogonlog}\\
|
|
|
|
\helpref{GetActiveTarget}{wxloggetactivetarget}\\
|
1998-10-07 07:04:27 -04:00
|
|
|
\helpref{SetActiveTarget}{wxlogsetactivetarget}\\
|
1998-09-29 20:48:01 -04:00
|
|
|
\helpref{DontCreateOnDemand}{wxlogdontcreateondemand}
|
|
|
|
|
|
|
|
\membersection{Message buffering}
|
|
|
|
|
|
|
|
Some of wxLog implementations, most notably the standard
|
1998-11-17 17:44:47 -05:00
|
|
|
wxLogGui class, buffer the messages (for example, to avoid
|
1998-09-29 20:48:01 -04:00
|
|
|
showing the user a zillion of modal message boxes one after another - which
|
|
|
|
would be really annoying). {\it Flush()} shows them all and clears the buffer
|
|
|
|
contents. Although this function doesn't do anything if the buffer is already
|
|
|
|
empty, {\it HasPendingMessages()} is also provided which allows to explicitly
|
|
|
|
verify it.
|
|
|
|
|
|
|
|
\helpref{Flush}{wxlogflush}\\
|
1999-10-07 14:18:07 -04:00
|
|
|
\helpref{FlushActive}{wxlogflushactive}\\
|
1998-09-29 20:48:01 -04:00
|
|
|
\helpref{HasPendingMessages}{haspendingmessages}
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{Customization}\label{wxlogcustomization}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
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).
|
|
|
|
|
|
|
|
The verbose messages are the trace messages which are not disabled in the
|
2000-02-23 08:17:14 -05:00
|
|
|
release mode and are generated by \helpref{wxLogVerbose}{wxlogverbose}. 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.
|
1998-09-29 20:48:01 -04:00
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
As for the (real) trace messages, their handling depends on the settings of
|
|
|
|
the (application global) {\it trace mask}. There are two ways to specify it:
|
2000-02-23 08:17:14 -05:00
|
|
|
either by using \helpref{SetTraceMask}{wxlogsettracemask} and
|
1999-11-18 09:34:13 -05:00
|
|
|
\helpref{GetTraceMask}{wxloggettracemask} and using
|
|
|
|
\helpref{wxLogTrace}{wxlogtrace} which takes an integer mask or by using
|
|
|
|
\helpref{AddTraceMask}{wxlogaddtracemask} for string trace masks.
|
|
|
|
|
|
|
|
The difference between bit-wise and string trace masks is that a message using
|
|
|
|
integer trace mask will only be logged if all bits of the mask are set in the
|
|
|
|
current mask while a message using string mask will be logged simply if the
|
|
|
|
mask had been added before to the list of allowed ones.
|
|
|
|
|
|
|
|
For example,
|
2000-03-14 19:21:49 -05:00
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
\begin{verbatim}
|
|
|
|
// wxTraceOleCalls is one of standard bit masks
|
|
|
|
wxLogTrace(wxTraceRefCount | wxTraceOleCalls, "Active object ref count: %d", nRef);
|
|
|
|
\end{verbatim}
|
|
|
|
will do something only if the current trace mask contains both
|
|
|
|
{\tt wxTraceRefCount} and {\tt wxTraceOle}, but
|
2000-03-14 19:21:49 -05:00
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
\begin{verbatim}
|
|
|
|
// wxTRACE_OleCalls is one of standard string masks
|
2000-02-23 08:17:14 -05:00
|
|
|
wxLogTrace(wxTRACE_OleCalls, "IFoo::Bar() called");
|
1999-11-18 09:34:13 -05:00
|
|
|
\end{verbatim}
|
2000-03-14 19:21:49 -05:00
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
will log the message if it was preceded by
|
2000-03-14 19:21:49 -05:00
|
|
|
|
1998-09-29 20:48:01 -04:00
|
|
|
\begin{verbatim}
|
1999-11-18 09:34:13 -05:00
|
|
|
wxLog::AddTraceMask(wxTRACE_OleCalls);
|
1998-09-29 20:48:01 -04:00
|
|
|
\end{verbatim}
|
1999-11-18 09:34:13 -05:00
|
|
|
|
|
|
|
Using string masks is simpler and allows to easily add custom ones, so this is
|
|
|
|
the preferred way of working with trace messages. The integer trace mask is
|
|
|
|
kept for compatibility and for additional (but very rarely needed) flexibility
|
|
|
|
only.
|
|
|
|
|
|
|
|
The standard trace masks are given in \helpref{wxLogTrace}{wxlogtrace}
|
|
|
|
documentation.
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
Finally, the {\it wxLog::DoLog()} 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 {\it strftime()} 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.
|
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
{\bf NB:} Timestamping is disabled for Visual C++ users in debug builds by
|
|
|
|
default because otherwise it would be impossible to directly go to the line
|
|
|
|
from which the log message was generated by simply clicking in the debugger
|
|
|
|
window on the corresponding error message. If you wish to enable it, please use
|
|
|
|
\helpref{SetTimestamp}{wxlogsettimestamp} explicitly.
|
|
|
|
|
|
|
|
\helpref{AddTraceMask}{wxlogaddtracemask}\\
|
|
|
|
\helpref{RemoveTraceMask}{wxlogremovetracemask}\\
|
|
|
|
\helpref{IsAllowedTraceMask}{wxlogisallowedtracemask}\\
|
1998-09-29 20:48:01 -04:00
|
|
|
\helpref{SetVerbose}{wxlogsetverbose}\\
|
|
|
|
\helpref{GetVerbose}{wxloggetverbose}\\
|
1999-08-05 18:05:15 -04:00
|
|
|
\helpref{SetTimestamp}{wxlogsettimestamp}\\
|
|
|
|
\helpref{GetTimestamp}{wxloggettimestamp}\\
|
1998-09-29 20:48:01 -04:00
|
|
|
\helpref{SetTraceMask}{wxlogsettracemask}\\
|
|
|
|
\helpref{GetTraceMask}{wxloggettracemask}
|
|
|
|
|
|
|
|
%%%%% MEMBERS HERE %%%%%
|
|
|
|
\helponly{\insertatlevel{2}{
|
|
|
|
|
|
|
|
\wxheading{Members}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
\membersection{wxLog::AddTraceMask}\label{wxlogaddtracemask}
|
|
|
|
|
|
|
|
\func{static void}{AddTraceMask}{\param{const wxString\& }{mask}}
|
|
|
|
|
|
|
|
Add the {\it mask} to the list of allowed masks for
|
|
|
|
\helpref{wxLogTrace}{wxlogtrace}.
|
|
|
|
|
|
|
|
See also: \helpref{RemoveTraceMask}{wxlogremovetracemask}
|
|
|
|
|
1998-09-29 20:48:01 -04:00
|
|
|
\membersection{wxLog::OnLog}\label{wxlogonlog}
|
|
|
|
|
|
|
|
\func{static void}{OnLog}{\param{wxLogLevel }{ level}, \param{const char * }{ message}}
|
|
|
|
|
|
|
|
Forwards the message at specified level to the {\it DoLog()} function of the
|
|
|
|
active log target if there is any, does nothing otherwise.
|
|
|
|
|
|
|
|
\membersection{wxLog::GetActiveTarget}\label{wxloggetactivetarget}
|
|
|
|
|
|
|
|
\func{static wxLog *}{GetActiveTarget}{\void}
|
|
|
|
|
|
|
|
Returns the pointer to the active log target (may be NULL).
|
|
|
|
|
|
|
|
\membersection{wxLog::SetActiveTarget}\label{wxlogsetactivetarget}
|
|
|
|
|
|
|
|
\func{static wxLog *}{SetActiveTarget}{\param{wxLog * }{ logtarget}}
|
|
|
|
|
|
|
|
Sets the specified log target as the active one. Returns the pointer to the
|
|
|
|
previous active log target (may be NULL).
|
|
|
|
|
|
|
|
\membersection{wxLog::DontCreateOnDemand}\label{wxlogdontcreateondemand}
|
|
|
|
|
|
|
|
\func{static void}{DontCreateOnDemand}{\void}
|
|
|
|
|
|
|
|
Instructs wxLog to not create new log targets on the fly if there is none
|
|
|
|
currently. (Almost) for internal use only.
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::Flush}\label{wxlogflush}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
\func{virtual void}{Flush}{\void}
|
|
|
|
|
|
|
|
Shows all the messages currently in buffer and clears it. If the buffer
|
|
|
|
is already empty, nothing happens.
|
|
|
|
|
1999-10-07 14:18:07 -04:00
|
|
|
\membersection{wxLog::FlushActive}\label{wxlogflushactive}
|
|
|
|
|
|
|
|
\func{static void}{FlushActive}{\void}
|
|
|
|
|
|
|
|
Flushes the current log target if any, does nothing if there is none.
|
|
|
|
|
|
|
|
See also:
|
|
|
|
|
|
|
|
\helpref{Flush}{wxlogflush}
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::HasPendingMessages}\label{haspendingmessages}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
\constfunc{bool}{HasPendingMessages}{\void}
|
|
|
|
|
|
|
|
Returns true if there are any messages in the buffer (not yet shown to the
|
|
|
|
user). (Almost) for internal use only.
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::SetVerbose}\label{wxlogsetverbose}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
\func{void}{SetVerbose}{\param{bool }{ verbose = TRUE}}
|
|
|
|
|
|
|
|
Activates or desactivates verbose mode in which the verbose messages are
|
|
|
|
logged as the normal ones instead of being silently dropped.
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::GetVerbose}\label{wxloggetverbose}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
\constfunc{bool}{GetVerbose}{\void}
|
|
|
|
|
|
|
|
Returns whether the verbose mode is currently active.
|
|
|
|
|
1999-08-05 18:05:15 -04:00
|
|
|
\membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
1999-08-05 18:05:15 -04:00
|
|
|
\func{void}{SetTimestamp}{\param{const char * }{ format}}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
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 {\it strftime()} manual for details.
|
1999-09-02 04:23:23 -04:00
|
|
|
Passing a NULL value (not empty string) to this function disables message timestamping.
|
1998-09-29 20:48:01 -04:00
|
|
|
|
1999-08-05 18:05:15 -04:00
|
|
|
\membersection{wxLog::GetTimestamp}\label{wxloggettimestamp}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
1999-08-05 18:05:15 -04:00
|
|
|
\constfunc{const char *}{GetTimestamp}{\void}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
Returns the current timestamp format string.
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::SetTraceMask}\label{wxlogsettracemask}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
|
|
|
\func{static void}{SetTraceMask}{\param{wxTraceMask }{ mask}}
|
|
|
|
|
|
|
|
Sets the trace mask, see \helpref{Customization}{wxlogcustomization}
|
|
|
|
section for details.
|
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
\membersection{wxLog::GetTraceMask}\label{wxloggettracemask}
|
1998-09-29 20:48:01 -04:00
|
|
|
|
1998-10-07 07:04:27 -04:00
|
|
|
Returns the current trace mask, see \helpref{Customization}{wxlogcustomization} section
|
|
|
|
for details.
|
1998-12-28 07:35:49 -05:00
|
|
|
|
1999-11-18 09:34:13 -05:00
|
|
|
\membersection{wxLog::IsAllowedTraceMask}\label{wxlogisallowedtracemask}
|
|
|
|
|
|
|
|
\func{static bool}{IsAllowedTraceMask}{\param{const wxChar *}{mask}}
|
|
|
|
|
|
|
|
Returns TRUE if the {\it mask} is one of allowed masks for
|
|
|
|
\helpref{wxLogTrace}{wxlogtrace}.
|
|
|
|
|
|
|
|
See also: \helpref{AddTraceMask}{wxlogaddtracemask},
|
|
|
|
\helpref{RemoveTraceMask}{wxlogremovetracemask}
|
|
|
|
|
|
|
|
\membersection{wxLog::RemoveTraceMask}\label{wxlogremovetracemask}
|
|
|
|
|
|
|
|
\func{static void}{RemoveTraceMask}{\param{const wxString\& }{mask}}
|
|
|
|
|
|
|
|
Remove the {\it mask} from the list of allowed masks for
|
|
|
|
\helpref{wxLogTrace}{wxlogtrace}.
|
|
|
|
|
|
|
|
See also: \helpref{AddTraceMask}{wxlogaddtracemask}
|
|
|
|
|