mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
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:
parent
5d7e07508a
commit
3d594e16dd
68 changed files with 212 additions and 79 deletions
|
|
@ -18,8 +18,10 @@
|
|||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "logcat.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logColorQuantizer, "quickshell.colorquantizer", QtWarningMsg);
|
||||
QS_LOGGING_CATEGORY(logColorQuantizer, "quickshell.colorquantizer", QtWarningMsg);
|
||||
}
|
||||
|
||||
ColorQuantizerOperation::ColorQuantizerOperation(QUrl* source, qreal depth, qreal rescaleSize)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
#include <ranges>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "logcat.hpp"
|
||||
#include "model.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logDesktopEntry, "quickshell.desktopentry", QtWarningMsg);
|
||||
QS_LOGGING_CATEGORY(logDesktopEntry, "quickshell.desktopentry", QtWarningMsg);
|
||||
}
|
||||
|
||||
struct Locale {
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@
|
|||
#include "iconimageprovider.hpp"
|
||||
#include "imageprovider.hpp"
|
||||
#include "incubator.hpp"
|
||||
#include "logcat.hpp"
|
||||
#include "plugin.hpp"
|
||||
#include "qsintercept.hpp"
|
||||
#include "reload.hpp"
|
||||
#include "scan.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logScene, "scene");
|
||||
QS_LOGGING_CATEGORY(logScene, "scene");
|
||||
}
|
||||
|
||||
static QHash<const QQmlEngine*, EngineGeneration*> g_generations; // NOLINT
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#include "incubator.hpp"
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qqmlincubator.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(logIncubator, "quickshell.incubator", QtWarningMsg);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_LOGGING_CATEGORY(logIncubator, "quickshell.incubator", QtWarningMsg);
|
||||
|
||||
void QsQmlIncubator::statusChanged(QQmlIncubator::Status status) {
|
||||
switch (status) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <qloggingcategory.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlincubator.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logIncubator);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_DECLARE_LOGGING_CATEGORY(logIncubator);
|
||||
|
||||
class QsQmlIncubator
|
||||
: public QObject
|
||||
|
|
|
|||
28
src/core/logcat.hpp
Normal file
28
src/core/logcat.hpp
Normal 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) (); \
|
||||
}
|
||||
|
|
@ -30,17 +30,18 @@
|
|||
#include <sys/sendfile.h>
|
||||
|
||||
#include "instanceinfo.hpp"
|
||||
#include "logcat.hpp"
|
||||
#include "logging_p.hpp"
|
||||
#include "logging_qtprivate.cpp" // NOLINT
|
||||
#include "paths.hpp"
|
||||
#include "ringbuf.hpp"
|
||||
|
||||
Q_LOGGING_CATEGORY(logBare, "quickshell.bare");
|
||||
QS_LOGGING_CATEGORY(logBare, "quickshell.bare");
|
||||
|
||||
namespace qs::log {
|
||||
using namespace qt_logging_registry;
|
||||
|
||||
Q_LOGGING_CATEGORY(logLogging, "quickshell.logging", QtWarningMsg);
|
||||
QS_LOGGING_CATEGORY(logLogging, "quickshell.logging", QtWarningMsg);
|
||||
|
||||
bool LogMessage::operator==(const LogMessage& other) const {
|
||||
// note: not including time
|
||||
|
|
@ -187,10 +188,16 @@ void LogManager::filterCategory(QLoggingCategory* category) {
|
|||
// We don't respect log filters for qs logs because some distros like to ship
|
||||
// default configs that hide everything. QT_LOGGING_RULES is considered via the filter list.
|
||||
if (isQs) {
|
||||
filter.debug = instance->mDefaultLevel == QtDebugMsg;
|
||||
filter.info = instance->mDefaultLevel == QtInfoMsg;
|
||||
filter.warn = instance->mDefaultLevel == QtWarningMsg;
|
||||
filter.critical = instance->mDefaultLevel == QtCriticalMsg;
|
||||
// QtDebugMsg == 0, so default
|
||||
auto defaultLevel = instance->defaultLevels.value(categoryName);
|
||||
|
||||
filter = CategoryFilter();
|
||||
// clang-format off
|
||||
filter.debug = instance->mDefaultLevel == QtDebugMsg || defaultLevel == QtDebugMsg;
|
||||
filter.info = filter.debug || instance->mDefaultLevel == QtInfoMsg || defaultLevel == QtInfoMsg;
|
||||
filter.warn = filter.info || instance->mDefaultLevel == QtWarningMsg || defaultLevel == QtWarningMsg;
|
||||
filter.critical = filter.warn || instance->mDefaultLevel == QtCriticalMsg || defaultLevel == QtCriticalMsg;
|
||||
// clang-format on
|
||||
} else if (instance->lastCategoryFilter) {
|
||||
instance->lastCategoryFilter(category);
|
||||
filter = CategoryFilter(category);
|
||||
|
|
@ -262,6 +269,10 @@ void LogManager::init(
|
|||
qCDebug(logLogging) << "Logger initialized.";
|
||||
}
|
||||
|
||||
void initLogCategoryLevel(const char* name, QtMsgType defaultLevel) {
|
||||
LogManager::instance()->defaultLevels.insert(QLatin1StringView(name), defaultLevel);
|
||||
}
|
||||
|
||||
void LogManager::initFs() {
|
||||
QMetaObject::invokeMethod(
|
||||
&LogManager::instance()->threadProxy,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include <qbytearrayview.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qfile.h>
|
||||
|
|
@ -12,7 +13,9 @@
|
|||
#include <qobject.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logBare);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_DECLARE_LOGGING_CATEGORY(logBare);
|
||||
|
||||
namespace qs::log {
|
||||
|
||||
|
|
@ -127,11 +130,14 @@ private:
|
|||
QString mRulesString;
|
||||
QList<qt_logging_registry::QLoggingRule>* rules = nullptr;
|
||||
QtMsgType mDefaultLevel = QtWarningMsg;
|
||||
QHash<QLatin1StringView, QtMsgType> defaultLevels;
|
||||
QHash<const void*, CategoryFilter> sparseFilters;
|
||||
QHash<QLatin1StringView, CategoryFilter> allFilters;
|
||||
|
||||
QTextStream stdoutStream;
|
||||
LoggingThreadProxy threadProxy;
|
||||
|
||||
friend void initLogCategoryLevel(const char* name, QtMsgType defaultLevel);
|
||||
};
|
||||
|
||||
bool readEncodedLogs(
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@
|
|||
#include <qstringview.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "logcat.hpp"
|
||||
#include "logging_qtprivate.hpp"
|
||||
|
||||
namespace qs::log {
|
||||
Q_DECLARE_LOGGING_CATEGORY(logLogging);
|
||||
QS_DECLARE_LOGGING_CATEGORY(logLogging);
|
||||
|
||||
namespace qt_logging_registry {
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@
|
|||
#include <qstringview.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "logcat.hpp"
|
||||
|
||||
namespace qs::log {
|
||||
Q_DECLARE_LOGGING_CATEGORY(logLogging);
|
||||
QS_DECLARE_LOGGING_CATEGORY(logLogging);
|
||||
|
||||
namespace qt_logging_registry {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "instanceinfo.hpp"
|
||||
#include "logcat.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logPaths, "quickshell.paths", QtWarningMsg);
|
||||
QS_LOGGING_CATEGORY(logPaths, "quickshell.paths");
|
||||
}
|
||||
|
||||
QsPaths* QsPaths::instance() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@
|
|||
#include <qtypes.h>
|
||||
#include <qurl.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(logQsIntercept, "quickshell.interceptor", QtWarningMsg);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_LOGGING_CATEGORY(logQsIntercept, "quickshell.interceptor", QtWarningMsg);
|
||||
|
||||
QUrl QsUrlInterceptor::intercept(
|
||||
const QUrl& originalUrl,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
#include <qqmlnetworkaccessmanagerfactory.h>
|
||||
#include <qurl.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logQsIntercept);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_DECLARE_LOGGING_CATEGORY(logQsIntercept);
|
||||
|
||||
class QsUrlInterceptor: public QQmlAbstractUrlInterceptor {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@
|
|||
#include <qstringliteral.h>
|
||||
#include <qtextstream.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(logQmlScanner, "quickshell.qmlscanner", QtWarningMsg);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_LOGGING_CATEGORY(logQmlScanner, "quickshell.qmlscanner", QtWarningMsg);
|
||||
|
||||
void QmlScanner::scanDir(const QString& path) {
|
||||
if (this->scannedDirs.contains(path)) return;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
#include <qloggingcategory.h>
|
||||
#include <qvector.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logQmlScanner);
|
||||
#include "logcat.hpp"
|
||||
|
||||
QS_DECLARE_LOGGING_CATEGORY(logQmlScanner);
|
||||
|
||||
// expects canonical paths
|
||||
class QmlScanner {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue