6#include <QtCore/qfile.h>
7#include <QtCore/qlibraryinfo.h>
8#include <QtCore/private/qlocking_p.h>
9#include <QtCore/qstandardpaths.h>
10#include <QtCore/qstringtokenizer.h>
11#include <QtCore/qtextstream.h>
12#include <QtCore/qdir.h>
13#include <QtCore/qcoreapplication.h>
15#if QT_CONFIG(settings)
16#include <QtCore/qsettings.h>
17#include <QtCore/private/qsettings_p.h>
22#define debugMsg QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, "qt.core.logging").debug
23#define warnMsg QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, "qt.core.logging").warning
102 if (
pattern.endsWith(
".debug"_L1)) {
105 }
else if (
pattern.endsWith(
".info"_L1)) {
108 }
else if (
pattern.endsWith(
".warning"_L1)) {
111 }
else if (
pattern.endsWith(
".critical"_L1)) {
118 const QChar asterisk = u
'*';
119 if (!
p.contains(asterisk)) {
122 if (
p.endsWith(asterisk)) {
126 if (
p.startsWith(asterisk)) {
130 if (
p.contains(asterisk))
131 flags = PatternFlags();
196 if (m_inRulesSection) {
198 if (equalPos != -1) {
201#if QT_CONFIG(settings)
210 if (valueStr ==
"true"_L1)
212 else if (valueStr ==
"false"_L1)
231 : categoryFilter(defaultCategoryFilter)
233#if defined(Q_OS_ANDROID)
261 return parser.
rules();
285 er += parser.
rules();
290#if !defined(QT_BOOTSTRAPPED)
305 ruleSets[EnvironmentRules] = std::move(er);
306 ruleSets[QtConfigRules] = std::move(qr);
307 ruleSets[ConfigRules] = std::move(cr);
309 if (!ruleSets[EnvironmentRules].isEmpty() || !ruleSets[QtConfigRules].isEmpty() || !ruleSets[ConfigRules].isEmpty())
321 const auto locker = qt_scoped_lock(registryMutex);
328 (*categoryFilter)(cat);
338 const auto locker = qt_scoped_lock(registryMutex);
353 qtCategoryEnvironmentOverrides.
insert(categoryName, environment);
367 debugMsg(
"Loading logging rules set by QLoggingCategory::setFilterRules ...");
371 ruleSets[ApiRules] = parser.
rules();
382void QLoggingRegistry::updateRules()
385 (*categoryFilter)(*it);
395 const auto locker = qt_scoped_lock(registryMutex);
398 filter = defaultCategoryFilter;
410 return qtLoggingRegistry();
430 bool critical = warning || (enableForLevel ==
QtCriticalMsg);
437 if (strcmp(categoryName,
"qt") == 0) {
439 }
else if (strncmp(categoryName,
"qt.", 3) == 0) {
441 auto it = reg->qtCategoryEnvironmentOverrides.
find(categoryName);
442 if (
it == reg->qtCategoryEnvironmentOverrides.
end())
451 for (
const auto &ruleSet : reg->ruleSets) {
452 for (
const auto &
rule : ruleSet) {
455 debug = (filterpass > 0);
458 info = (filterpass > 0);
461 warning = (filterpass > 0);
464 critical = (filterpass > 0);
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QByteArray & replace(qsizetype index, qsizetype len, const char *s, qsizetype alen)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString toNativeSeparators(const QString &pathName)
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
constexpr qsizetype size() const noexcept
qsizetype indexOf(QStringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
static QString path(LibraryPath p)
void append(parameter_type t)
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.
const char * categoryName() const
Returns the name of the category.
void unregisterCategory(QLoggingCategory *category)
static QLoggingRegistry * instance()
void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel)
QLoggingCategory::CategoryFilter installFilter(QLoggingCategory::CategoryFilter filter)
Q_CORE_EXPORT void registerEnvironmentOverrideForCategory(QByteArrayView categoryName, QByteArrayView environment)
void setApiRules(const QString &content)
int pass(QLatin1StringView categoryName, QtMsgType type) const
void setImplicitRulesSection(bool inRulesSection)
QList< QLoggingRule > rules() const
void setContent(QStringView content)
iterator insert(const Key &key, const T &value)
iterator find(const Key &key)
static bool iniUnescapedKey(QByteArrayView key, QString &result)
static QString locate(StandardLocation type, const QString &fileName, LocateOptions options=LocateFile)
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString trimmed() const &
QString chopped(qsizetype n) const
QByteArray toUtf8() const &
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char * rule
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
static QList< QLoggingRule > loadRulesFromFile(const QString &filePath)
static bool qtLoggingDebug()
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei GLenum * categories
#define QStringLiteral(str)
constexpr auto qTokenize(Haystack &&h, Needle &&n, Flags...flags) noexcept(QtPrivate::Tok::is_nothrow_constructible_from< Haystack, Needle >::value) -> decltype(QtPrivate::Tok::TokenizerResult< Haystack, Needle >{std::forward< Haystack >(h), std::forward< Needle >(n), flags...})
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QFileInfo info(fileName)
[8]