quickshell/src/core/logcat.hpp
outfoxxed 3d594e16dd
core/log: track default logging categories
Fixes a bug in fb37be7 which ignored default logging categories due to
skipping QLoggingRegistry's filter.
2025-07-08 13:49:06 -07:00

28 lines
1.7 KiB
C++

#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) (); \
}