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:
@@ -8,9 +8,11 @@ import Quickshell.Hyprland
|
||||
import Quickshell.I3
|
||||
import Quickshell.Wayland
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
readonly property var log: Log.scoped("SessionService")
|
||||
|
||||
property bool hasUwsm: false
|
||||
property bool isElogind: false
|
||||
@@ -64,15 +66,15 @@ Singleton {
|
||||
detectHibernateProcess.running = true;
|
||||
detectPrimeRunProcess.running = true;
|
||||
detectWtypeProcess.running = true;
|
||||
console.info("SessionService: Native inhibitor available:", nativeInhibitorAvailable);
|
||||
log.info("Native inhibitor available:", nativeInhibitorAvailable);
|
||||
if (!SettingsData.loginctlLockIntegration) {
|
||||
console.log("SessionService: loginctl lock integration disabled by user");
|
||||
log.debug("loginctl lock integration disabled by user");
|
||||
return;
|
||||
}
|
||||
if (socketPath && socketPath.length > 0) {
|
||||
checkDMSCapabilities();
|
||||
} else {
|
||||
console.log("SessionService: DMS_SOCKET not set");
|
||||
log.debug("DMS_SOCKET not set");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +95,7 @@ Singleton {
|
||||
command: ["sh", "-c", "ps -eo comm= | grep -E '^(elogind|elogind-daemon)$'"]
|
||||
|
||||
onExited: function (exitCode) {
|
||||
console.log("SessionService: Elogind detection exited with code", exitCode);
|
||||
log.debug("Elogind detection exited with code", exitCode);
|
||||
isElogind = (exitCode === 0);
|
||||
}
|
||||
}
|
||||
@@ -396,7 +398,7 @@ Singleton {
|
||||
if (idleInhibited) {
|
||||
return;
|
||||
}
|
||||
console.log("SessionService: Enabling idle inhibit (native:", nativeInhibitorAvailable, ")");
|
||||
log.debug("Enabling idle inhibit (native:", nativeInhibitorAvailable, ")");
|
||||
idleInhibited = true;
|
||||
inhibitorChanged();
|
||||
}
|
||||
@@ -405,7 +407,7 @@ Singleton {
|
||||
if (!idleInhibited) {
|
||||
return;
|
||||
}
|
||||
console.log("SessionService: Disabling idle inhibit (native:", nativeInhibitorAvailable, ")");
|
||||
log.debug("Disabling idle inhibit (native:", nativeInhibitorAvailable, ")");
|
||||
idleInhibited = false;
|
||||
inhibitorChanged();
|
||||
}
|
||||
@@ -441,19 +443,19 @@ Singleton {
|
||||
return ["true"];
|
||||
}
|
||||
|
||||
console.log("SessionService: Starting systemd/elogind inhibit process");
|
||||
log.debug("Starting systemd/elogind inhibit process");
|
||||
return [isElogind ? "elogind-inhibit" : "systemd-inhibit", "--what=idle", "--who=quickshell", `--why=${inhibitReason}`, "--mode=block", "sleep", "infinity"];
|
||||
}
|
||||
|
||||
running: idleInhibited && !nativeInhibitorAvailable
|
||||
|
||||
onRunningChanged: {
|
||||
console.log("SessionService: Inhibit process running:", running, "(native:", nativeInhibitorAvailable, ")");
|
||||
log.debug("Inhibit process running:", running, "(native:", nativeInhibitorAvailable, ")");
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (idleInhibited && exitCode !== 0 && !nativeInhibitorAvailable) {
|
||||
console.warn("SessionService: Inhibitor process crashed with exit code:", exitCode);
|
||||
log.warn("Inhibitor process crashed with exit code:", exitCode);
|
||||
idleInhibited = false;
|
||||
ToastService.showWarning("Idle inhibitor failed");
|
||||
}
|
||||
@@ -545,7 +547,7 @@ Singleton {
|
||||
}
|
||||
} else {
|
||||
loginctlAvailable = false;
|
||||
console.log("SessionService: loginctl capability not available in DMS");
|
||||
log.debug("loginctl capability not available in DMS");
|
||||
}
|
||||
|
||||
if (DMSService.capabilities.includes("dbus")) {
|
||||
@@ -574,7 +576,7 @@ Singleton {
|
||||
prepareForSleepSubscriptionPending = false;
|
||||
|
||||
if (response.error) {
|
||||
console.warn("SessionService: Failed to subscribe to PrepareForSleep:", response.error);
|
||||
log.warn("Failed to subscribe to PrepareForSleep:", response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -621,9 +623,9 @@ Singleton {
|
||||
enabled: SettingsData.lockBeforeSuspend
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("SessionService: Failed to sync lock before suspend:", response.error);
|
||||
log.warn("Failed to sync lock before suspend:", response.error);
|
||||
} else {
|
||||
console.log("SessionService: Synced lock before suspend:", SettingsData.lockBeforeSuspend);
|
||||
log.debug("Synced lock before suspend:", SettingsData.lockBeforeSuspend);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -637,9 +639,9 @@ Singleton {
|
||||
enabled: SettingsData.loginctlLockIntegration && SettingsData.lockBeforeSuspend
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("SessionService: Failed to sync sleep inhibitor:", response.error);
|
||||
log.warn("Failed to sync sleep inhibitor:", response.error);
|
||||
} else {
|
||||
console.log("SessionService: Synced sleep inhibitor:", SettingsData.loginctlLockIntegration);
|
||||
log.debug("Synced sleep inhibitor:", SettingsData.loginctlLockIntegration);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user