Add component-level filtering to wxLog.

Each log message is now associated with its component, "wx" by default for
messages generated by wxWidgets and wxLOG_COMPONENT in general (which is empty
by default). Each component may have its own log level and they are
hierarchical allowing fine configuration of what exactly is logged.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-07-12 14:56:23 +00:00
parent fbbde24964
commit c602c59b6e
5 changed files with 293 additions and 58 deletions

View File

@@ -828,11 +828,14 @@ public:
Returns true if logging at this level is enabled.
This function only returns @true if logging is globally enabled and if
this level is less than or equal to the global log level value.
@a level is less than or equal to the maximal log level enabled for the
given @a component.
@see IsEnabled(), SetLogLevel(), GetLogLevel()
@see IsEnabled(), SetLogLevel(), GetLogLevel(), SetComponentLevel()
@since 2.9.1
*/
static bool IsLevelEnabled(wxLogLevel level);
static bool IsLevelEnabled(wxLogLevel level, wxString component);
/**
Remove the @a mask from the list of allowed masks for
@@ -858,9 +861,33 @@ public:
*/
static wxLog* SetActiveTarget(wxLog* logtarget);
/**
Sets the log level for the given component.
For example, to disable all but error messages from wxWidgets network
classes you may use
@code
wxLog::SetComponentLevel("wx/net", wxLOG_Error);
@endcode
SetLogLevel() may be used to set the global log level.
@param component
Non-empty component name, possibly using slashes (@c /) to separate
it into several parts.
@param level
Maximal level of log messages from this component which will be
handled instead of being simply discarded.
@since 2.9.1
*/
static void SetComponentLevel(const wxString& component, wxLogLevel level);
/**
Specifies that log messages with level greater (numerically) than
@a logLevel should be ignored and not sent to the active log target.
@see SetComponentLevel()
*/
static void SetLogLevel(wxLogLevel logLevel);