Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qloggingcategory.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qloggingcategory.h"
6
8
9const char qtDefaultCategoryName[] = "default";
11
12
173 : d(nullptr),
174 name(nullptr)
175{
176 init(category, enableForLevel);
177}
178
179void QLoggingCategory::init(const char *category, QtMsgType severityLevel)
180{
181 enabled.storeRelaxed(0x01010101); // enabledDebug = enabledWarning = enabledCritical = true;
182
183 if (category)
184 name = category;
185 else
187
189 reg->registerCategory(this, severityLevel);
190}
191
196{
198 reg->unregisterCategory(this);
199}
200
260{
261 switch (msgtype) {
262 case QtDebugMsg: return isDebugEnabled();
263 case QtInfoMsg: return isInfoEnabled();
264 case QtWarningMsg: return isWarningEnabled();
265 case QtCriticalMsg: return isCriticalEnabled();
266 case QtFatalMsg: return true;
267 }
268 return false;
269}
270
281{
282 switch (type) {
283 case QtDebugMsg: bools.enabledDebug.storeRelaxed(enable); break;
284 case QtInfoMsg: bools.enabledInfo.storeRelaxed(enable); break;
285 case QtWarningMsg: bools.enabledWarning.storeRelaxed(enable); break;
286 case QtCriticalMsg: bools.enabledCritical.storeRelaxed(enable); break;
287 case QtFatalMsg: break;
288 }
289}
290
316{
317 return qtDefaultCategory();
318}
319
370
384{
385 QLoggingRegistry::instance()->setApiRules(rules);
386}
387
void storeRelaxed(T newValue) noexcept
\inmodule QtCore
static void setFilterRules(const QString &rules)
Configures which categories and message types should be enabled through a set of rules.
~QLoggingCategory()
Destroys a QLoggingCategory object.
bool isInfoEnabled() const
Returns true if informational messages should be shown for this category; false otherwise.
static QLoggingCategory * defaultCategory()
Returns a pointer to the global category "default" that is used, for example, by qDebug(),...
void(* CategoryFilter)(QLoggingCategory *)
This is a typedef for a pointer to a function with the following signature:
void setEnabled(QtMsgType type, bool enable)
Changes the message type type for the category to enable.
static CategoryFilter installFilter(CategoryFilter)
Take control of how logging categories are configured.
bool isWarningEnabled() const
Returns true if warning messages should be shown for this category; false otherwise.
bool isEnabled(QtMsgType type) const
Returns true if a message of type msgtype for the category should be shown; false otherwise.
bool isCriticalEnabled() const
Returns true if critical messages should be shown for this category; false otherwise.
bool isDebugEnabled() const
Returns true if debug messages should be shown for this category; false otherwise.
static QLoggingRegistry * instance()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
const QLoggingCategory & category()
[1]
Combined button and popup list for selecting options.
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
QtMsgType
Definition qlogging.h:29
@ QtCriticalMsg
Definition qlogging.h:32
@ QtInfoMsg
Definition qlogging.h:34
@ QtWarningMsg
Definition qlogging.h:31
@ QtFatalMsg
Definition qlogging.h:33
@ QtDebugMsg
Definition qlogging.h:30
QT_BEGIN_NAMESPACE const char qtDefaultCategoryName[]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum type
GLboolean enable
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint name
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)