![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qloggingcategory.h>
Public Types | |
typedef void(* | CategoryFilter) (QLoggingCategory *) |
This is a typedef for a pointer to a function with the following signature: | |
Public Member Functions | |
QLoggingCategory (const char *category, QtMsgType severityLevel=QtDebugMsg) | |
Constructs a QLoggingCategory object with the provided category name, and enables all messages with types at least as verbose as enableForLevel, which defaults to QtDebugMsg (which enables all categories). | |
~QLoggingCategory () | |
Destroys a QLoggingCategory object. | |
bool | isEnabled (QtMsgType type) const |
Returns true if a message of type msgtype for the category should be shown; false otherwise. | |
void | setEnabled (QtMsgType type, bool enable) |
Changes the message type type for the category to enable. | |
bool | isDebugEnabled () const |
Returns true if debug messages should be shown for this category; false otherwise. | |
bool | isInfoEnabled () const |
Returns true if informational messages should be shown for this category; false otherwise. | |
bool | isWarningEnabled () const |
Returns true if warning messages should be shown for this category; false otherwise. | |
bool | isCriticalEnabled () const |
Returns true if critical messages should be shown for this category; false otherwise. | |
const char * | categoryName () const |
Returns the name of the category. | |
QLoggingCategory & | operator() () |
Returns the object itself. | |
const QLoggingCategory & | operator() () const |
Returns the object itself. | |
Static Public Member Functions | |
static QLoggingCategory * | defaultCategory () |
Returns a pointer to the global category "default" that is used, for example, by qDebug(), qInfo(), qWarning(), qCritical(), or qFatal(). | |
static CategoryFilter | installFilter (CategoryFilter) |
Take control of how logging categories are configured. | |
static void | setFilterRules (const QString &rules) |
Configures which categories and message types should be enabled through a set of rules. | |
\inmodule QtCore
The QLoggingCategory class represents a category, or 'area' in the logging infrastructure.
QLoggingCategory represents a certain logging category - identified by a string - at runtime. A category can be configured to enable or disable logging of messages per message type. An exception are fatal messages, which are always enabled.
To check whether a message type is enabled or not, use one of these methods: \l isDebugEnabled(), \l isInfoEnabled(), \l isWarningEnabled(), and \l isCriticalEnabled().
All objects are meant to be configured by a common registry, as described in \l{Configuring Categories}. Different objects can also represent the same category. Therefore, it's {not} recommended to export objects across module boundaries, to manipulate the objects directly, or to inherit from QLoggingCategory.
Definition at line 12 of file qloggingcategory.h.
typedef void(* QLoggingCategory::CategoryFilter) (QLoggingCategory *) |
This is a typedef for a pointer to a function with the following signature:
A function with this signature can be installed with \l installFilter().
Definition at line 35 of file qloggingcategory.h.
|
explicit |
Constructs a QLoggingCategory object with the provided category name, and enables all messages with types at least as verbose as enableForLevel, which defaults to QtDebugMsg (which enables all categories).
If category is \nullptr, the category name "default"
is used.
Definition at line 172 of file qloggingcategory.cpp.
QLoggingCategory::~QLoggingCategory | ( | ) |
Destroys a QLoggingCategory object.
Definition at line 190 of file qloggingcategory.cpp.
|
inline |
Returns the name of the category.
Definition at line 27 of file qloggingcategory.h.
|
static |
Returns a pointer to the global category "default"
that is used, for example, by qDebug(), qInfo(), qWarning(), qCritical(), or qFatal().
delete
this pointer, as ownership of the category isn't transferred. Definition at line 310 of file qloggingcategory.cpp.
|
static |
Take control of how logging categories are configured.
Installs a function filter that is used to determine which categories and message types should be enabled. If filter is \nullptr, the default message filter is reinstated. Returns a pointer to the previously-installed filter.
Every QLoggingCategory object that already exists is passed to the filter before installFilter()
returns, and the filter is free to change each category's configuration with \l setEnabled(). Any category it doesn't change will retain the configuration it was given by the prior filter, so the new filter does not need to delegate to the prior filter during this initial pass over existing categories.
Any new categories added later will be passed to the new filter; a filter that only aims to tweak the configuration of a select few categories, rather than completely overriding the logging policy, can first pass the new category to the prior filter, to give it its standard configuration, and then tweak that as desired, if it is one of the categories of specific interest to the filter. The code that installs the new filter can record the return from installFilter()
for the filter to use in such later calls.
When you define your filter, note that it can be called from different threads; but never concurrently. This filter cannot call any static functions from QLoggingCategory.
Example:
installed (in {main()}, for example) by
Alternatively, you can configure the default filter via \l setFilterRules().
Definition at line 361 of file qloggingcategory.cpp.
|
inline |
Returns true
if critical messages should be shown for this category; false
otherwise.
Definition at line 25 of file qloggingcategory.h.
|
inline |
Returns true
if debug messages should be shown for this category; false
otherwise.
Definition at line 22 of file qloggingcategory.h.
bool QLoggingCategory::isEnabled | ( | QtMsgType | type | ) | const |
Returns true
if a message of type msgtype for the category should be shown; false
otherwise.
Definition at line 254 of file qloggingcategory.cpp.
|
inline |
Returns true
if informational messages should be shown for this category; false
otherwise.
Definition at line 23 of file qloggingcategory.h.
|
inline |
Returns true
if warning messages should be shown for this category; false
otherwise.
Definition at line 24 of file qloggingcategory.h.
|
inline |
Returns the object itself.
This allows for both: a QLoggingCategory variable, and a factory method that returns a QLoggingCategory, to be used in \l qCDebug(), \l qCWarning(), \l qCCritical(), or \l qCFatal() macros.
Definition at line 30 of file qloggingcategory.h.
|
inline |
Returns the object itself.
This allows for both: a QLoggingCategory variable, and a factory method that returns a QLoggingCategory, to be used in \l qCDebug(), \l qCWarning(), \l qCCritical(), or \l qCFatal() macros.
Definition at line 31 of file qloggingcategory.h.
Changes the message type type for the category to enable.
This method is meant for use only from inside a filter installed with \l installFilter(). For an overview on how to configure categories globally, see \l {Configuring Categories}.
QtFatalMsg
cannot be changed; it will always remain true
. Definition at line 275 of file qloggingcategory.cpp.
Configures which categories and message types should be enabled through a set of rules.
Example:
QT_LOGGING_CONF
or the QT_LOGGING_RULES
environment variable. Definition at line 378 of file qloggingcategory.cpp.
AtomicBools QLoggingCategory::bools |
Definition at line 51 of file qloggingcategory.h.
QBasicAtomicInt QLoggingCategory::enabled |
Definition at line 52 of file qloggingcategory.h.