Struct qt_core::QLoggingCategory
source · #[repr(C)]pub struct QLoggingCategory { /* private fields */ }
Expand description
The QLoggingCategory class represents a category, or 'area' in the logging infrastructure.
C++ class: QLoggingCategory
.
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. Whether a message type is enabled or not can be checked with the isDebugEnabled(), isInfoEnabled(), isWarningEnabled(), and isCriticalEnabled() methods.
All objects are meant to be configured by a common registry (see also Configuring Categories). Different objects can also represent the same category. It is therefore not recommended to export objects across module boundaries, nor to manipulate the objects directly, nor to inherit from QLoggingCategory.
Implementations§
source§impl QLoggingCategory
impl QLoggingCategory
sourcepub unsafe fn call_mut(&self) -> Ref<QLoggingCategory>
pub unsafe fn call_mut(&self) -> Ref<QLoggingCategory>
Returns the object itself. This allows both a QLoggingCategory variable, and a factory method returning a QLoggingCategory, to be used in qCDebug(), qCWarning(), qCCritical() macros.
Calls C++ function: QLoggingCategory& QLoggingCategory::operator()()
.
Returns the object itself. This allows both a QLoggingCategory variable, and a factory method returning a QLoggingCategory, to be used in qCDebug(), qCWarning(), qCCritical() macros.
sourcepub unsafe fn call(&self) -> Ref<QLoggingCategory>
pub unsafe fn call(&self) -> Ref<QLoggingCategory>
Returns the object itself. This allows both a QLoggingCategory variable, and a factory method returning a QLoggingCategory, to be used in qCDebug(), qCWarning(), qCCritical() macros.
Calls C++ function: const QLoggingCategory& QLoggingCategory::operator()() const
.
Returns the object itself. This allows both a QLoggingCategory variable, and a factory method returning a QLoggingCategory, to be used in qCDebug(), qCWarning(), qCCritical() macros.
sourcepub unsafe fn category_name(&self) -> *const c_char
pub unsafe fn category_name(&self) -> *const c_char
Returns the name of the category.
Calls C++ function: const char* QLoggingCategory::categoryName() const
.
Returns the name of the category.
sourcepub unsafe fn default_category() -> Ptr<QLoggingCategory>
pub unsafe fn default_category() -> Ptr<QLoggingCategory>
sourcepub unsafe fn install_filter(
arg1: Option<extern "C" fn(_: *mut QLoggingCategory)>
) -> Option<extern "C" fn(_: *mut QLoggingCategory)>
pub unsafe fn install_filter( arg1: Option<extern "C" fn(_: *mut QLoggingCategory)> ) -> Option<extern "C" fn(_: *mut QLoggingCategory)>
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.
Calls C++ function: static void (*FN_PTR)(QLoggingCategory *) QLoggingCategory::installFilter(void (*FN_PTR)(QLoggingCategory *) arg1)
.
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 setEnabled().
The filter might be called from different threads, but never concurrently. The filter shall not call any static functions of QLoggingCategory.
Example:
QLoggingCategory::CategoryFilter oldCategoryFilter;
void myCategoryFilter(QLoggingCategory *category) { // configure driver.usb category here, otherwise forward to to default filter. if (qstrcmp(category->categoryName(), “driver.usb”) == 0) category->setEnabled(QtDebugMsg, true); else oldCategoryFilter(category); }
An alternative way of configuring the default filter is via setFilterRules().
sourcepub unsafe fn is_critical_enabled(&self) -> bool
pub unsafe fn is_critical_enabled(&self) -> bool
Returns true
if critical messages should be shown for this category. Returns false
otherwise.
Calls C++ function: bool QLoggingCategory::isCriticalEnabled() const
.
Returns true
if critical messages should be shown for this category. Returns false
otherwise.
Note: The qCCritical() macro already does this check before executing any code. However, calling this method may be useful to avoid expensive generation of data that is only used for debug output.
sourcepub unsafe fn is_debug_enabled(&self) -> bool
pub unsafe fn is_debug_enabled(&self) -> bool
Returns true
if debug messages should be shown for this category. Returns false
otherwise.
Calls C++ function: bool QLoggingCategory::isDebugEnabled() const
.
Returns true
if debug messages should be shown for this category. Returns false
otherwise.
Note: The qCDebug() macro already does this check before executing any code. However, calling this method may be useful to avoid expensive generation of data that is only used for debug output.
sourcepub unsafe fn is_enabled(&self, type_: QtMsgType) -> bool
pub unsafe fn is_enabled(&self, type_: QtMsgType) -> bool
Returns true
if a message of type msgtype for the category should be shown. Returns false
otherwise.
Calls C++ function: bool QLoggingCategory::isEnabled(QtMsgType type) const
.
Returns true
if a message of type msgtype for the category should be shown. Returns false
otherwise.
sourcepub unsafe fn is_info_enabled(&self) -> bool
pub unsafe fn is_info_enabled(&self) -> bool
Returns true
if informational messages should be shown for this category. Returns false
otherwise.
Calls C++ function: bool QLoggingCategory::isInfoEnabled() const
.
Returns true
if informational messages should be shown for this category. Returns false
otherwise.
Note: The qCInfo() macro already does this check before executing any code. However, calling this method may be useful to avoid expensive generation of data that is only used for debug output.
This function was introduced in Qt 5.5.
sourcepub unsafe fn is_warning_enabled(&self) -> bool
pub unsafe fn is_warning_enabled(&self) -> bool
Returns true
if warning messages should be shown for this category. Returns false
otherwise.
Calls C++ function: bool QLoggingCategory::isWarningEnabled() const
.
Returns true
if warning messages should be shown for this category. Returns false
otherwise.
Note: The qCWarning() macro already does this check before executing any code. However, calling this method may be useful to avoid expensive generation of data that is only used for debug output.
sourcepub unsafe fn new_1a(category: *const c_char) -> CppBox<QLoggingCategory>
pub unsafe fn new_1a(category: *const c_char) -> CppBox<QLoggingCategory>
Constructs a QLoggingCategory object with the provided category name. All message types for this category are enabled by default.
Calls C++ function: [constructor] void QLoggingCategory::QLoggingCategory(const char* category)
.
Constructs a QLoggingCategory object with the provided category name. All message types for this category are enabled by default.
If category is 0
, the category name is changed to "default"
.
sourcepub unsafe fn new_2a(
category: *const c_char,
severity_level: QtMsgType
) -> CppBox<QLoggingCategory>
pub unsafe fn new_2a( category: *const c_char, severity_level: QtMsgType ) -> CppBox<QLoggingCategory>
Constructs a QLoggingCategory object with the provided category name, and enables all messages with types more severe or equal than enableForLevel.
Calls C++ function: [constructor] void QLoggingCategory::QLoggingCategory(const char* category, QtMsgType severityLevel)
.
Constructs a QLoggingCategory object with the provided category name, and enables all messages with types more severe or equal than enableForLevel.
If category is 0
, the category name is changed to "default"
.
This function was introduced in Qt 5.4.
sourcepub unsafe fn set_enabled(&self, type_: QtMsgType, enable: bool)
pub unsafe fn set_enabled(&self, type_: QtMsgType, enable: bool)
Changes the message type type for the category to enable.
Calls C++ function: void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
.
Changes the message type type for the category to enable.
This method is meant to be used only from inside a filter installed by installFilter(). See Configuring Categories for an overview on how to configure categories globally.
Note: QtFatalMsg
cannot be changed. It will always remain true
.
See also isEnabled().
sourcepub unsafe fn set_filter_rules(rules: impl CastInto<Ref<QString>>)
pub unsafe fn set_filter_rules(rules: impl CastInto<Ref<QString>>)
Configures which categories and message types should be enabled through a a set of rules.
Calls C++ function: static void QLoggingCategory::setFilterRules(const QString& rules)
.
Configures which categories and message types should be enabled through a a set of rules.
Example:
QLoggingCategory::setFilterRules(QStringLiteral(“driver.usb.debug=true”));
Note: The rules might be ignored if a custom category filter is installed with installFilter(), or if the user defined QT_LOGGING_CONF
or QT_LOGGING_RULES
environment variable.
Trait Implementations§
source§impl CppDeletable for QLoggingCategory
impl CppDeletable for QLoggingCategory
source§unsafe fn delete(&self)
unsafe fn delete(&self)
Destructs a QLoggingCategory object.
Calls C++ function: [destructor] void QLoggingCategory::~QLoggingCategory()
.
Destructs a QLoggingCategory object.