QtBase
v6.3.1
|
The QLoggingCategory class represents a category, or 'area' in the logging infrastructure. More...
#include <qloggingcategory.h>
Public Types | |
typedef void(* | CategoryFilter) (QLoggingCategory *) |
Public Member Functions | |
QLoggingCategory (const char *category, QtMsgType severityLevel=QtDebugMsg) | |
~QLoggingCategory () | |
bool | isEnabled (QtMsgType type) const |
void | setEnabled (QtMsgType type, bool enable) |
bool | isDebugEnabled () const |
bool | isInfoEnabled () const |
bool | isWarningEnabled () const |
bool | isCriticalEnabled () const |
const char * | categoryName () const |
QLoggingCategory & | operator() () |
const QLoggingCategory & | operator() () const |
Static Public Member Functions | |
static QLoggingCategory * | defaultCategory () |
static CategoryFilter | installFilter (CategoryFilter) |
static void | setFilterRules (const QString &rules) |
The QLoggingCategory class represents a category, or 'area' in the logging infrastructure.
\inmodule QtCore
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.
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 48 of file qloggingcategory.h.
QLoggingCategory::CategoryFilter |
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 77 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 218 of file qloggingcategory.cpp.
QLoggingCategory::~QLoggingCategory | ( | ) |
Destroys a QLoggingCategory object.
Definition at line 241 of file qloggingcategory.cpp.
|
inline |
Returns the name of the category.
Definition at line 69 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 368 of file qloggingcategory.cpp.
|
static |
Installs a function filter that is used to determine which categories and message types should be enabled. Returns a pointer to the previous installed filter.
Every QLoggingCategory object created is passed to the filter, and the filter is free to change the respective category configuration with \l setEnabled().
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:
Alternatively, you can configure the default filter via \l setFilterRules().
Definition at line 401 of file qloggingcategory.cpp.
|
inline |
Returns true
if critical messages should be shown for this category; false
otherwise.
Definition at line 67 of file qloggingcategory.h.
|
inline |
Returns true
if debug messages should be shown for this category; false
otherwise.
Definition at line 64 of file qloggingcategory.h.
bool QLoggingCategory::isEnabled | ( | QtMsgType | msgtype | ) | const |
Returns true
if a message of type msgtype for the category should be shown; false
otherwise.
Definition at line 305 of file qloggingcategory.cpp.
|
inline |
Returns true
if informational messages should be shown for this category; false
otherwise.
Definition at line 65 of file qloggingcategory.h.
|
inline |
Returns true
if warning messages should be shown for this category; false
otherwise.
Definition at line 66 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(), or \l qCCritical() macros.
Definition at line 72 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(), or \l qCCritical() macros.
Definition at line 73 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 326 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 418 of file qloggingcategory.cpp.
AtomicBools QLoggingCategory::bools |
Definition at line 103 of file qloggingcategory.h.
QBasicAtomicInt QLoggingCategory::enabled |
Definition at line 104 of file qloggingcategory.h.