This class represents a background log window: to be precise, it collects all
log messages in the log frame which it manages but also passes them on to the
- log target which was active at the moment of its creation. This allows, for
+ log target which was active at the moment of its creation. This allows you, for
example, to show all the log messages in a frame but still continue to process
them normally by showing the standard log dialog.
@class wxLogChain
@wxheader{log.h}
- This simple class allows to chain log sinks, that is to install a new sink but
+ This simple class allows you to chain log sinks, that is to install a new sink but
keep passing log messages to the old one instead of replacing it completely as
wxLog::SetActiveTarget does.
/**
Sets another log target to use (may be @NULL). The log target specified
- in the @ref ctor() constructor or in a previous call to
+ in the wxLogChain(wxLog*) constructor or in a previous call to
this function is deleted.
This doesn't change the old log target value (the one the messages are
forwarded to) which still remains the same as was active when wxLogChain
method.
@library{wxbase}
- @category{FIXME}
+ @category{logging}
*/
class wxLogBuffer : public wxLog
{
@wxheader{log.h}
wxLog class defines the interface for the @e log targets used by wxWidgets
- logging functions as explained in the @ref overview_wxlogoverview "wxLog
- overview".
+ logging functions as explained in the @ref overview_log.
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
Otherwise, it is completely hidden behind the @e wxLogXXX() functions and
you may not even know about its existence.
- See @ref overview_wxlogoverview "log overview" for the descriptions of wxWidgets
- logging facilities.
-
- @library{wxcore}
- @category{logging}
-
- @see wxLog::RemoveTraceMask, wxLog::GetTraceMasks
-*/
-class wxLog
-{
-public:
- /**
- Add the @a mask to the list of allowed masks for
- wxLogTrace().
-
- @see RemoveTraceMask(), GetTraceMasks()
- */
- static void AddTraceMask(const wxString& mask);
-
- /**
- Removes all trace masks previously set with
- AddTraceMask().
+ @section overview_wxLog_deriving Deriving your own log target
+
+ There are two functions which must be implemented by any derived class to
+ actually process the log messages: DoLog() and
+ DoLogString(). The second function receives a string
+ which just has to be output in some way and the easiest way to write a new log
+ target is to override just this function in the derived class. If more control
+ over the output format is needed, then the first function must be overridden
+ which allows to construct custom messages depending on the log level or even
+ do completely different things depending on the message severity (for example,
+ throw away all messages except warnings and errors, show warnings on the
+ screen and forward the error messages to the user's (or programmer's) cell
+ phone - maybe depending on whether the timestamp tells us if it is day or
+ night in the current time zone).
+ There also functions to support message buffering. Why are they needed?
+ 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).
+ Flush() shows them all and clears the buffer contents.
+ This function doesn't do anything if the buffer is already empty.
+ See also:
+ @li Flush()
+ @li FlushActive()
- @see RemoveTraceMask()
- */
- static void ClearTraceMasks();
+ @section overview_wxLog_Trace_Masks Using trace masks
- /**
The functions below allow some limited customization of wxLog behaviour
- without writing a new log target class (which, aside of being a matter of
+ without writing a new log target class (which, aside from 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
release mode and are generated by wxLogVerbose(). They
may be activated, for example, in order to help the user find some program
problem.
As for the (real) trace messages, their handling depends on the settings of
- the (application global) @e trace mask. There are two ways to specify it:
- either by using SetTraceMask() and
- GetTraceMask() and using
- wxLogTrace() which takes an integer mask or by using
- AddTraceMask() for string trace masks.
+ the (application global) @e trace mask which can either be specified using
+ SetTraceMask(), GetTraceMask() and wxLogTrace() which takes an integer mask
+ or using AddTraceMask() 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,
+
+ @code
+ wxLogTrace( wxTraceRefCount|wxTraceOleCalls, "Active object ref count: %d", nRef );
+ @endcode
will do something only if the current trace mask contains both
@c wxTraceRefCount and @c wxTraceOle, but
+ @code
+ wxLogTrace( wxTRACE_OleCalls, "IFoo::Bar() called" );
+ @endcode
+
will log the message if it was preceded by
+
+ @code
+ wxLog::AddTraceMask( wxTRACE_OleCalls);
+ @endcode
- Using string masks is simpler and allows to easily add custom ones, so this is
+ Using string masks is simpler and allows you 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 wxLogTrace()
- documentation.
+ The standard trace masks are given in wxLogTrace() documentation.
Finally, the @e 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 % specifications fully described in the documentation of the
"[%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.
+ See also
+ @li AddTraceMask()
+ @li RemoveTraceMask()
+ @li ClearTraceMasks()
+ @li GetTraceMasks()
+ @li IsAllowedTraceMask()
+ @li SetVerbose()
+ @li GetVerbose()
+ @li SetTimestamp()
+ @li GetTimestamp()
+ @li SetTraceMask()
+ @li GetTraceMask()
+ @li SetRepetitionCounting()
+ @li GetRepetitionCounting()
+
@note 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
- SetTimestamp() explicitly.
- AddTraceMask()
-
- RemoveTraceMask()
-
- ClearTraceMasks()
+ window on the corresponding error message. If you wish to enable it, please
+ use SetTimestamp() explicitly.
+
+ @section overview_wxLog_Target Manipulating the log target
- GetTraceMasks()
-
- IsAllowedTraceMask()
-
- SetVerbose()
-
- GetVerbose()
+ The functions in this section work with and manipulate the active log
+ target. The OnLog() is called by the @e wxLogXXX() functions
+ and invokes the DoLog() of the active log target if any.
+ Get/Set methods are used to install/query the current active target and,
+ finally, 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. See also
+ @li OnLog()
+ @li GetActiveTarget()
+ @li SetActiveTarget()
+ @li DontCreateOnDemand()
+ @li Suspend()
+ @li Resume()
- SetTimestamp()
+ @library{wxcore}
+ @category{logging}
- GetTimestamp()
+ @see @ref overview_log
+*/
+class wxLog
+{
+public:
+ /**
+ Add the @a mask to the list of allowed masks for
+ wxLogTrace().
- SetTraceMask()
+ @see RemoveTraceMask(), GetTraceMasks()
+ */
+ static void AddTraceMask(const wxString& mask);
- GetTraceMask()
+ /**
+ Removes all trace masks previously set with
+ AddTraceMask().
- SetRepetitionCounting()
+ @see RemoveTraceMask()
+ */
+ static void ClearTraceMasks();
- GetRepetitionCounting()
*/
*/
static bool GetVerbose();
- /**
- The functions in this section work with and manipulate the active log target.
- The OnLog() is called by the @e wxLogXXX() functions
- and invokes the DoLog() of the active log target if any.
- Get/Set methods are used to install/query the current active target and,
- finally, 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.
- OnLog()
-
- GetActiveTarget()
-
- SetActiveTarget()
-
- DontCreateOnDemand()
-
- Suspend()
-
- Resume()
- */
-
-
/**
Returns @true if the @a mask is one of allowed masks for
wxLogTrace().
- See also: AddTraceMask(),
- RemoveTraceMask()
+
+ See also: AddTraceMask(), RemoveTraceMask()
*/
static bool IsAllowedTraceMask(const wxString& mask);
which just has to be output in some way and the easiest way to write a new log
target is to override just this function in the derived class. If more control
over the output format is needed, then the first function must be overridden
- which allows to construct custom messages depending on the log level or even
+ which allows you to construct custom messages depending on the log level or even
do completely different things depending on the message severity (for example,
throw away all messages except warnings and errors, show warnings on the
screen and forward the error messages to the user's (or programmer's) cell
@class wxLogNull
@wxheader{log.h}
- This class allows to temporarily suspend logging. All calls to the log
+ This class allows you to temporarily suspend logging. All calls to the log
functions during the life time of an object of this class are just ignored.
In particular, it can be used to suppress the log messages given by wxWidgets