diff --git a/modules/Shortcuts.qml b/modules/Shortcuts.qml index b4633e8f..9ee79676 100644 --- a/modules/Shortcuts.qml +++ b/modules/Shortcuts.qml @@ -1,3 +1,4 @@ +import QtQuick import Quickshell import Quickshell.Io import Caelestia @@ -115,7 +116,7 @@ Scope { const visibilities = Visibilities.getForActive(); visibilities[drawer] = !visibilities[drawer]; } else { - console.warn(`[IPC] Drawer "${drawer}" does not exist`); + console.warn(lc, `Drawer "${drawer}" does not exist`); } } @@ -154,4 +155,11 @@ Scope { target: "toaster" } + + LoggingCategory { + id: lc + + name: "caelestia.qml.shortcuts" + defaultLogLevel: LoggingCategory.Info + } } diff --git a/modules/controlcenter/appearance/AppearancePane.qml b/modules/controlcenter/appearance/AppearancePane.qml index c4222076..c0ccfcd7 100644 --- a/modules/controlcenter/appearance/AppearancePane.qml +++ b/modules/controlcenter/appearance/AppearancePane.qml @@ -136,7 +136,7 @@ Item { onStatusChanged: { if (status === Loader.Error) { - console.error("[AppearancePane] Wallpaper loader error!"); + console.error(lc, "Wallpaper loader error!"); } } @@ -259,4 +259,11 @@ Item { rightContent: appearanceRightContentComponent } + + LoggingCategory { + id: lc + + name: "caelestia.qml.controlcenter.appearance" + defaultLogLevel: LoggingCategory.Info + } } diff --git a/plugin/src/Caelestia/Internal/cachingimagemanager.cpp b/plugin/src/Caelestia/Internal/cachingimagemanager.cpp index 9f63f99a..46152d2a 100644 --- a/plugin/src/Caelestia/Internal/cachingimagemanager.cpp +++ b/plugin/src/Caelestia/Internal/cachingimagemanager.cpp @@ -6,9 +6,12 @@ #include #include #include +#include #include #include +Q_LOGGING_CATEGORY(lcCim, "caelestia.internal.cim", QtInfoMsg) + namespace caelestia::internal { qreal CachingImageManager::effectiveScale() const { @@ -132,7 +135,7 @@ void CachingImageManager::updateSource(const QString& path) { emit cachePathChanged(); if (!cache.isLocalFile()) { - qWarning() << "CachingImageManager::updateSource: cachePath" << cache << "is not a local file"; + qCWarning(lcCim) << "updateSource: cachePath" << cache << "is not a local file"; return; } @@ -161,7 +164,7 @@ void CachingImageManager::createCache( QImage image(path); if (image.isNull()) { - qWarning() << "CachingImageManager::createCache: failed to read" << path; + qCWarning(lcCim) << "createCache: failed to read" << path; return; } @@ -188,7 +191,7 @@ void CachingImageManager::createCache( const QString parent = QFileInfo(cache).absolutePath(); if (!QDir().mkpath(parent) || !image.save(cache)) { - qWarning() << "CachingImageManager::createCache: failed to save to" << cache; + qCWarning(lcCim) << "createCache: failed to save to" << cache; } }); } @@ -196,7 +199,7 @@ void CachingImageManager::createCache( QString CachingImageManager::sha256sum(const QString& path) { QFile file(path); if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "CachingImageManager::sha256sum: failed to open" << path; + qCWarning(lcCim) << "sha256sum: failed to open" << path; return ""; } diff --git a/plugin/src/Caelestia/Internal/hyprextras.cpp b/plugin/src/Caelestia/Internal/hyprextras.cpp index ab18d2f4..e95dfa57 100644 --- a/plugin/src/Caelestia/Internal/hyprextras.cpp +++ b/plugin/src/Caelestia/Internal/hyprextras.cpp @@ -3,8 +3,11 @@ #include #include #include +#include #include +Q_LOGGING_CATEGORY(lcHypr, "caelestia.internal.hypr", QtInfoMsg) + namespace caelestia::internal::hypr { HyprExtras::HyprExtras(QObject* parent) @@ -16,8 +19,7 @@ HyprExtras::HyprExtras(QObject* parent) , m_devices(new HyprDevices(this)) { const auto his = qEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE"); if (his.isEmpty()) { - qWarning() - << "HyprExtras::HyprExtras: $HYPRLAND_INSTANCE_SIGNATURE is unset. Unable to connect to Hyprland socket."; + qCWarning(lcHypr) << "$HYPRLAND_INSTANCE_SIGNATURE is unset. Unable to connect to Hyprland socket."; return; } @@ -26,8 +28,7 @@ HyprExtras::HyprExtras(QObject* parent) hyprDir = "/tmp/hypr/" + his; if (!QDir(hyprDir).exists()) { - qWarning() << "HyprExtras::HyprExtras: Hyprland socket directory does not exist. Unable to connect to " - "Hyprland socket."; + qCWarning(lcHypr) << "Hyprland socket directory does not exist. Unable to connect to Hyprland socket."; return; } } @@ -62,7 +63,7 @@ void HyprExtras::message(const QString& message) { makeRequest(message, [](bool success, const QByteArray& res) { if (!success) { - qWarning() << "HyprExtras::message: request error:" << QString::fromUtf8(res); + qCWarning(lcHypr) << "message: request error:" << QString::fromUtf8(res); } }); } @@ -74,7 +75,7 @@ void HyprExtras::batchMessage(const QStringList& messages) { makeRequest("[[BATCH]]" + messages.join(";"), [](bool success, const QByteArray& res) { if (!success) { - qWarning() << "HyprExtras::batchMessage: request error:" << QString::fromUtf8(res); + qCWarning(lcHypr) << "batchMessage: request error:" << QString::fromUtf8(res); } }); } @@ -95,7 +96,7 @@ void HyprExtras::applyOptions(const QVariantHash& options) { if (success) { refreshOptions(); } else { - qWarning() << "HyprExtras::applyOptions: request error" << QString::fromUtf8(res); + qCWarning(lcHypr) << "applyOptions: request error" << QString::fromUtf8(res); } }); } @@ -145,15 +146,15 @@ void HyprExtras::refreshDevices() { void HyprExtras::socketError(QLocalSocket::LocalSocketError error) const { if (!m_socketValid) { - qWarning() << "HyprExtras::socketError: unable to connect to Hyprland event socket:" << error; + qCWarning(lcHypr) << "socketError: unable to connect to Hyprland event socket:" << error; } else { - qWarning() << "HyprExtras::socketError: Hyprland event socket error:" << error; + qCWarning(lcHypr) << "socketError: Hyprland event socket error:" << error; } } void HyprExtras::socketStateChanged(QLocalSocket::LocalSocketState state) { if (state == QLocalSocket::UnconnectedState && m_socketValid) { - qWarning() << "HyprExtras::socketStateChanged: Hyprland event socket disconnected."; + qCWarning(lcHypr) << "socketStateChanged: Hyprland event socket disconnected."; } m_socketValid = state == QLocalSocket::ConnectedState; @@ -206,7 +207,7 @@ HyprExtras::SocketPtr HyprExtras::makeRequest( }); QObject::connect(socket.data(), &QLocalSocket::errorOccurred, this, [=](QLocalSocket::LocalSocketError err) { - qWarning() << "HyprExtras::makeRequest: error making request:" << err << "| request:" << request; + qCWarning(lcHypr) << "makeRequest: error making request:" << err << "| request:" << request; callback(false, {}); socket->close(); }); diff --git a/plugin/src/Caelestia/Internal/logindmanager.cpp b/plugin/src/Caelestia/Internal/logindmanager.cpp index 4194ee1e..740005d9 100644 --- a/plugin/src/Caelestia/Internal/logindmanager.cpp +++ b/plugin/src/Caelestia/Internal/logindmanager.cpp @@ -4,6 +4,9 @@ #include #include #include +#include + +Q_LOGGING_CATEGORY(lcLogindManager, "caelestia.internal.logindmanager", QtInfoMsg) namespace caelestia::internal { @@ -11,7 +14,7 @@ LogindManager::LogindManager(QObject* parent) : QObject(parent) { auto bus = QDBusConnection::systemBus(); if (!bus.isConnected()) { - qWarning() << "LogindManager::LogindManager: failed to connect to system bus:" << bus.lastError().message(); + qCWarning(lcLogindManager) << "Failed to connect to system bus:" << bus.lastError().message(); return; } @@ -19,14 +22,13 @@ LogindManager::LogindManager(QObject* parent) "PrepareForSleep", this, SLOT(handlePrepareForSleep(bool))); if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to PrepareForSleep signal:" - << bus.lastError().message(); + qCWarning(lcLogindManager) << "Failed to connect to PrepareForSleep signal:" << bus.lastError().message(); } QDBusInterface login1("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", bus); const QDBusReply reply = login1.call("GetSession", "auto"); if (!reply.isValid()) { - qWarning() << "LogindManager::LogindManager: failed to get session path"; + qCWarning(lcLogindManager) << "Failed to get session path"; return; } const auto sessionPath = reply.value().path(); @@ -35,14 +37,14 @@ LogindManager::LogindManager(QObject* parent) SLOT(handleLockRequested())); if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to Lock signal:" << bus.lastError().message(); + qCWarning(lcLogindManager) << "Failed to connect to Lock signal:" << bus.lastError().message(); } ok = bus.connect("org.freedesktop.login1", sessionPath, "org.freedesktop.login1.Session", "Unlock", this, SLOT(handleUnlockRequested())); if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to Unlock signal:" << bus.lastError().message(); + qCWarning(lcLogindManager) << "Failed to connect to Unlock signal:" << bus.lastError().message(); } } diff --git a/plugin/src/Caelestia/Services/audiocollector.cpp b/plugin/src/Caelestia/Services/audiocollector.cpp index 72b9ce6b..69309f75 100644 --- a/plugin/src/Caelestia/Services/audiocollector.cpp +++ b/plugin/src/Caelestia/Services/audiocollector.cpp @@ -3,13 +3,16 @@ #include "service.hpp" #include #include -#include +#include #include #include #include #include #include +Q_LOGGING_CATEGORY(lcAc, "caelestia.services.ac", QtInfoMsg) +Q_LOGGING_CATEGORY(lcAcWorker, "caelestia.services.ac.worker", QtInfoMsg) + namespace caelestia::services { PipeWireWorker::PipeWireWorker(std::stop_token token, AudioCollector* collector) @@ -23,7 +26,7 @@ PipeWireWorker::PipeWireWorker(std::stop_token token, AudioCollector* collector) m_loop = pw_main_loop_new(nullptr); if (!m_loop) { - qWarning() << "PipeWireWorker::init: failed to create PipeWire main loop"; + qCWarning(lcAcWorker) << "init: failed to create PipeWire main loop"; pw_deinit(); return; } @@ -31,7 +34,7 @@ PipeWireWorker::PipeWireWorker(std::stop_token token, AudioCollector* collector) timespec timeout = { 0, 10 * SPA_NSEC_PER_MSEC }; m_timer = pw_loop_add_timer(pw_main_loop_get_loop(m_loop), handleTimeout, this); if (!m_timer) { - qWarning() << "PipeWireWorker::init: failed to create timer"; + qCWarning(lcAcWorker) << "init: failed to create timer"; pw_main_loop_destroy(m_loop); pw_deinit(); return; @@ -73,7 +76,7 @@ PipeWireWorker::PipeWireWorker(std::stop_token token, AudioCollector* collector) m_stream = pw_stream_new_simple(pw_main_loop_get_loop(m_loop), "caelestia-shell", props, &events, this); if (!m_stream) { - qWarning() << "PipeWireWorker::init: failed to create stream"; + qCWarning(lcAcWorker) << "init: failed to create stream"; pw_main_loop_destroy(m_loop); pw_deinit(); return; @@ -84,7 +87,7 @@ PipeWireWorker::PipeWireWorker(std::stop_token token, AudioCollector* collector) PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS), params, 1); if (success < 0) { - qWarning() << "PipeWireWorker::init: failed to connect stream"; + qCWarning(lcAcWorker) << "init: failed to connect stream"; pw_stream_destroy(m_stream); pw_main_loop_destroy(m_loop); pw_deinit(); diff --git a/plugin/src/Caelestia/Services/audioprovider.cpp b/plugin/src/Caelestia/Services/audioprovider.cpp index 1fac9eea..d2916f45 100644 --- a/plugin/src/Caelestia/Services/audioprovider.cpp +++ b/plugin/src/Caelestia/Services/audioprovider.cpp @@ -2,9 +2,12 @@ #include "audiocollector.hpp" #include "service.hpp" -#include +#include #include +Q_LOGGING_CATEGORY(lcAp, "caelestia.services.ap", QtInfoMsg) +Q_LOGGING_CATEGORY(lcApProcessor, "caelestia.services.ap.processor", QtInfoMsg) + namespace caelestia::services { AudioProcessor::AudioProcessor(QObject* parent) @@ -48,7 +51,7 @@ AudioProvider::~AudioProvider() { void AudioProvider::init() { if (!m_processor) { - qWarning() << "AudioProvider::init: attempted to init with no processor set"; + qCWarning(lcAp) << "init: attempted to init with no processor set"; return; } diff --git a/plugin/src/Caelestia/Services/cavaprovider.cpp b/plugin/src/Caelestia/Services/cavaprovider.cpp index 7b6cc1f2..a57f4040 100644 --- a/plugin/src/Caelestia/Services/cavaprovider.cpp +++ b/plugin/src/Caelestia/Services/cavaprovider.cpp @@ -4,7 +4,10 @@ #include "audioprovider.hpp" #include #include -#include +#include + +Q_LOGGING_CATEGORY(lcCava, "caelestia.services.cava", QtInfoMsg) +Q_LOGGING_CATEGORY(lcCavaProcessor, "caelestia.services.cava.processor", QtInfoMsg) namespace caelestia::services { @@ -57,7 +60,7 @@ void CavaProcessor::process() { void CavaProcessor::setBars(int bars) { if (bars < 0) { - qWarning() << "CavaProcessor::setBars: bars must be greater than 0. Setting to 0."; + qCWarning(lcCavaProcessor) << "setBars: bars must be greater than 0. Setting to 0."; bars = 0; } @@ -109,7 +112,7 @@ int CavaProvider::bars() const { void CavaProvider::setBars(int bars) { if (bars < 0) { - qWarning() << "CavaProvider::setBars: bars must be greater than 0. Setting to 0."; + qCWarning(lcCava) << "setBars: bars must be greater than 0. Setting to 0."; bars = 0; } diff --git a/plugin/src/Caelestia/Services/service.cpp b/plugin/src/Caelestia/Services/service.cpp index bc215671..4e1921e8 100644 --- a/plugin/src/Caelestia/Services/service.cpp +++ b/plugin/src/Caelestia/Services/service.cpp @@ -1,6 +1,5 @@ #include "service.hpp" -#include #include namespace caelestia::services { diff --git a/plugin/src/Caelestia/appdb.cpp b/plugin/src/Caelestia/appdb.cpp index 1e33990d..8d80ced9 100644 --- a/plugin/src/Caelestia/appdb.cpp +++ b/plugin/src/Caelestia/appdb.cpp @@ -1,9 +1,12 @@ #include "appdb.hpp" +#include #include #include #include +Q_LOGGING_CATEGORY(lcAppDb, "caelestia.appdb", QtInfoMsg) + namespace caelestia { AppEntry::AppEntry(QObject* entry, unsigned int frequency, QObject* parent) @@ -180,7 +183,7 @@ void AppDb::setFavouriteApps(const QStringList& favApps) { if (re.isValid()) { m_favouriteAppsRegex << re; } else { - qWarning() << "AppDb::setFavouriteApps: Regular expression is not valid: " << re.pattern(); + qCWarning(lcAppDb) << "setFavouriteApps: regular expression is not valid:" << re.pattern(); } } @@ -218,7 +221,7 @@ void AppDb::incrementFrequency(const QString& id) { emit appsChanged(); } } else { - qWarning() << "AppDb::incrementFrequency: could not find app with id" << id; + qCWarning(lcAppDb) << "incrementFrequency: could not find app with id" << id; } } diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index b6ec33a8..28a0e178 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -6,8 +6,11 @@ #include #include #include +#include #include +Q_LOGGING_CATEGORY(lcCUtils, "caelestia.cutils", QtInfoMsg) + namespace caelestia { void CUtils::saveItem(QQuickItem* target, const QUrl& path) { @@ -32,17 +35,17 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, QJSValue onSaved, QJSValue onFailed) { if (!target) { - qWarning() << "CUtils::saveItem: a target is required"; + qCWarning(lcCUtils) << "saveItem: a target is required"; return; } if (!path.isLocalFile()) { - qWarning() << "CUtils::saveItem:" << path << "is not a local file"; + qCWarning(lcCUtils) << "saveItem:" << path << "is not a local file"; return; } if (!target->window()) { - qWarning() << "CUtils::saveItem: unable to save target" << target << "without a window"; + qCWarning(lcCUtils) << "saveItem: unable to save target" << target << "without a window"; return; } @@ -82,7 +85,7 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q onSaved.call(args); } } else { - qWarning() << "CUtils::saveItem: failed to save" << path; + qCWarning(lcCUtils) << "saveItem: failed to save" << path; if (onFailed.isCallable()) { if (engine) { onFailed.call({ engine->toScriptValue(QVariant::fromValue(path)) }); @@ -99,17 +102,17 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q bool CUtils::copyFile(const QUrl& source, const QUrl& target, bool overwrite) const { if (!source.isLocalFile()) { - qWarning() << "CUtils::copyFile: source" << source << "is not a local file"; + qCWarning(lcCUtils) << "copyFile: source" << source << "is not a local file"; return false; } if (!target.isLocalFile()) { - qWarning() << "CUtils::copyFile: target" << target << "is not a local file"; + qCWarning(lcCUtils) << "copyFile: target" << target << "is not a local file"; return false; } if (overwrite && QFile::exists(target.toLocalFile())) { if (!QFile::remove(target.toLocalFile())) { - qWarning() << "CUtils::copyFile: overwrite was specified but failed to remove" << target.toLocalFile(); + qCWarning(lcCUtils) << "copyFile: overwrite was specified but failed to remove" << target.toLocalFile(); return false; } } @@ -119,7 +122,7 @@ bool CUtils::copyFile(const QUrl& source, const QUrl& target, bool overwrite) co bool CUtils::deleteFile(const QUrl& path) const { if (!path.isLocalFile()) { - qWarning() << "CUtils::deleteFile: path" << path << "is not a local file"; + qCWarning(lcCUtils) << "deleteFile: path" << path << "is not a local file"; return false; } @@ -128,7 +131,7 @@ bool CUtils::deleteFile(const QUrl& path) const { QString CUtils::toLocalFile(const QUrl& url) const { if (!url.isLocalFile()) { - qWarning() << "CUtils::toLocalFile: given url is not a local file" << url; + qCWarning(lcCUtils) << "toLocalFile: given url is not a local file" << url; return QString(); } diff --git a/plugin/src/Caelestia/imageanalyser.cpp b/plugin/src/Caelestia/imageanalyser.cpp index 0b623162..7f3ba526 100644 --- a/plugin/src/Caelestia/imageanalyser.cpp +++ b/plugin/src/Caelestia/imageanalyser.cpp @@ -4,8 +4,11 @@ #include #include #include +#include #include +Q_LOGGING_CATEGORY(lcImageAnalyser, "caelestia.imageanalyser", QtInfoMsg) + namespace caelestia { ImageAnalyser::ImageAnalyser(QObject* parent) @@ -152,7 +155,7 @@ void ImageAnalyser::update() { void ImageAnalyser::analyse(QPromise& promise, const QImage& image, int rescaleSize) { if (image.isNull()) { - qWarning() << "ImageAnalyser::analyse: image is null"; + qCWarning(lcImageAnalyser) << "analyse: image is null"; return; } diff --git a/plugin/src/Caelestia/requests.cpp b/plugin/src/Caelestia/requests.cpp index dbc746ed..862dea7f 100644 --- a/plugin/src/Caelestia/requests.cpp +++ b/plugin/src/Caelestia/requests.cpp @@ -1,11 +1,14 @@ #include "requests.hpp" #include +#include #include #include #include #include +Q_LOGGING_CATEGORY(lcRequests, "caelestia.requests", QtInfoMsg) + namespace caelestia { Requests::Requests(QObject* parent) @@ -14,7 +17,7 @@ Requests::Requests(QObject* parent) void Requests::get(const QUrl& url, QJSValue onSuccess, QJSValue onError, QJSValue headers) const { if (!onSuccess.isCallable()) { - qWarning() << "Requests::get: onSuccess is not callable"; + qCWarning(lcRequests) << "get: onSuccess is not callable"; return; } @@ -41,7 +44,7 @@ void Requests::get(const QUrl& url, QJSValue onSuccess, QJSValue onError, QJSVal } else if (onError.isCallable()) { onError.call({ reply->errorString() }); } else { - qWarning() << "Requests::get: request failed with error" << reply->errorString(); + qCWarning(lcRequests) << "get: request failed with error" << reply->errorString(); } reply->deleteLater(); diff --git a/plugin/src/Caelestia/toaster.cpp b/plugin/src/Caelestia/toaster.cpp index 978805de..b51c77f8 100644 --- a/plugin/src/Caelestia/toaster.cpp +++ b/plugin/src/Caelestia/toaster.cpp @@ -1,6 +1,5 @@ #include "toaster.hpp" -#include #include #include diff --git a/services/Nmcli.qml b/services/Nmcli.qml index dc783f8a..ea5d7eb3 100644 --- a/services/Nmcli.qml +++ b/services/Nmcli.qml @@ -391,7 +391,7 @@ Singleton { } if (!result.success && root.pendingConnection && retries < maxRetries) { - console.warn("[NMCLI] Connection failed, retrying... (attempt " + (retries + 1) + "/" + maxRetries + ")"); + console.warn(lc, "Connection failed, retrying... (attempt " + (retries + 1) + "/" + maxRetries + ")"); Qt.callLater(() => { connectWireless(ssid, password, bssid, callback, retries + 1); }, 1000); @@ -417,7 +417,7 @@ Singleton { loadSavedConnections(() => {}); activateConnection(ssid, callback); } else { - console.warn("[NMCLI] Connection profile creation failed, trying fallback..."); + console.warn(lc, "Connection profile creation failed, trying fallback..."); let fallbackCmd = [root.nmcliCommandDevice, root.nmcliCommandWifi, "connect", ssid, root.connectionParamPassword, password]; executeCommand(fallbackCmd, fallbackResult => { if (callback) @@ -1277,6 +1277,13 @@ Singleton { } } + LoggingCategory { + id: lc + + name: "caelestia.qml.services.nmcli" + defaultLogLevel: LoggingCategory.Info + } + component CommandProcess: Process { id: proc diff --git a/services/VPN.qml b/services/VPN.qml index bfeacea4..31b68319 100644 --- a/services/VPN.qml +++ b/services/VPN.qml @@ -454,7 +454,7 @@ Singleton { onStreamFinished: { const error = text.trim(); if (error && !error.includes("[#]")) { - console.warn("VPN disconnection error:", error); + console.warn(lc, "Disconnection error:", error); } } } @@ -476,4 +476,11 @@ Singleton { interval: 500 onTriggered: root.checkStatus() } + + LoggingCategory { + id: lc + + name: "caelestia.qml.services.vpn" + defaultLogLevel: LoggingCategory.Info + } }