core/log: track default logging categories

Fixes a bug in fb37be7 which ignored default logging categories due to
skipping QLoggingRegistry's filter.
This commit is contained in:
outfoxxed 2025-07-08 13:39:34 -07:00
parent 5d7e07508a
commit 3d594e16dd
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
68 changed files with 212 additions and 79 deletions

28
src/core/logcat.hpp Normal file
View file

@ -0,0 +1,28 @@
#pragma once
#include <qlogging.h>
#include <qloggingcategory.h>
namespace qs::log {
void initLogCategoryLevel(const char* name, QtMsgType defaultLevel = QtDebugMsg);
}
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define QS_DECLARE_LOGGING_CATEGORY(name) \
namespace qslogcat { \
Q_DECLARE_LOGGING_CATEGORY(name); \
} \
const QLoggingCategory& name()
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define QS_LOGGING_CATEGORY(name, category, ...) \
namespace qslogcat { \
Q_LOGGING_CATEGORY(name, category __VA_OPT__(, __VA_ARGS__)); \
} \
const QLoggingCategory& name() { \
static auto* init = []() { \
qs::log::initLogCategoryLevel(category __VA_OPT__(, __VA_ARGS__)); \
return &qslogcat::name; \
}(); \
return (init) (); \
}