forked from quickshell/quickshell
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
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue