1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-30 17:42:06 -04:00

logger: add a dedicated QML logging Singleton

- adds log.info/error/debug/warn/fatal
- adds ability to write logs to any file
- add CLI options in addition to env to set log levels
This commit is contained in:
bbedward
2026-04-29 15:40:44 -04:00
parent 3b96c6ab22
commit f76724f7cd
84 changed files with 1764 additions and 1297 deletions

View File

@@ -3,9 +3,11 @@ pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import qs.Services
Singleton {
id: root
readonly property var log: Log.scoped("NetworkService")
property bool networkAvailable: activeService !== null
property string backend: activeService?.backend ?? ""
@@ -97,12 +99,12 @@ Singleton {
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
Component.onCompleted: {
console.info("NetworkService: Initializing...");
log.info("Initializing...");
if (!socketPath || socketPath.length === 0) {
console.info("NetworkService: DMS_SOCKET not set, using LegacyNetworkService");
log.info("DMS_SOCKET not set, using LegacyNetworkService");
useLegacyService();
} else {
console.log("NetworkService: DMS_SOCKET found, waiting for capabilities...");
log.debug("DMS_SOCKET found, waiting for capabilities...");
}
}
@@ -111,13 +113,13 @@ Singleton {
function onNetworkAvailableChanged() {
if (!activeService && DMSNetworkService.networkAvailable) {
console.info("NetworkService: Network capability detected, using DMSNetworkService");
log.info("Network capability detected, using DMSNetworkService");
activeService = DMSNetworkService;
usingLegacy = false;
console.info("NetworkService: Switched to DMSNetworkService, networkAvailable:", networkAvailable);
log.info("Switched to DMSNetworkService, networkAvailable:", networkAvailable);
connectSignals();
} else if (!activeService && !DMSNetworkService.networkAvailable && socketPath && socketPath.length > 0) {
console.info("NetworkService: Network capability not available in DMS, using LegacyNetworkService");
log.info("Network capability not available in DMS, using LegacyNetworkService");
useLegacyService();
}
}
@@ -126,7 +128,7 @@ Singleton {
function useLegacyService() {
activeService = LegacyNetworkService;
usingLegacy = true;
console.info("NetworkService: Switched to LegacyNetworkService, networkAvailable:", networkAvailable);
log.info("Switched to LegacyNetworkService, networkAvailable:", networkAvailable);
if (LegacyNetworkService.activate) {
LegacyNetworkService.activate();
}