Using a custom logger with colors and timestamp instead of console.xxx

This commit is contained in:
quadbyte 2025-08-16 19:31:22 -04:00
parent 4794477be3
commit e800bc161d
34 changed files with 278 additions and 236 deletions

View file

@ -72,9 +72,9 @@ NLoader {
property string searchText: ""
property int selectedIndex: 0
property var filteredEntries: {
console.log("[AppLauncher] Total desktop entries:", desktopEntries ? desktopEntries.length : 0)
Logger.log("AppLauncher", "Total desktop entries:", desktopEntries ? desktopEntries.length : 0)
if (!desktopEntries || desktopEntries.length === 0) {
console.log("[AppLauncher] No desktop entries available")
Logger.log("AppLauncher", "No desktop entries available")
return []
}
@ -86,7 +86,7 @@ NLoader {
return true
})
console.log("[AppLauncher] Visible entries:", visibleEntries.length)
Logger.log("AppLauncher", "Visible entries:", visibleEntries.length)
var query = searchText ? searchText.toLowerCase() : ""
var results = []
@ -225,16 +225,16 @@ NLoader {
}))
}
console.log("[AppLauncher] Filtered entries:", results.length)
Logger.log("AppLauncher", "Filtered entries:", results.length)
return results
}
Component.onCompleted: {
console.log("[AppLauncher] Component completed")
console.log("[AppLauncher] DesktopEntries available:", typeof DesktopEntries !== 'undefined')
Logger.log("AppLauncher", "Component completed")
Logger.log("AppLauncher", "DesktopEntries available:", typeof DesktopEntries !== 'undefined')
if (typeof DesktopEntries !== 'undefined') {
console.log("[AppLauncher] DesktopEntries.entries:",
DesktopEntries.entries ? DesktopEntries.entries.length : 'undefined')
Logger.log("AppLauncher", "DesktopEntries.entries:",
DesktopEntries.entries ? DesktopEntries.entries.length : 'undefined')
}
// Start clipboard refresh immediately on open
updateClipboardHistory()

View file

@ -11,9 +11,9 @@ NLoader {
Component.onCompleted: {
if (WorkspacesService.isNiri) {
console.log("[Overview] Loading Overview component (Niri detected)")
Logger.log("Overview", "Loading Overview component (Niri detected)")
} else {
console.log("[Overview] Skipping Overview component (Niri not detected)")
Logger.log("Overview", "Skipping Overview component (Niri not detected)")
}
}

View file

@ -14,12 +14,12 @@ NIconButton {
sizeMultiplier: 0.8
showBorder: false
visible: bluetoothEnabled
Component.onCompleted: {
console.log("[Bluetooth] Component loaded, bluetoothEnabled:", bluetoothEnabled)
console.log("[Bluetooth] BluetoothService available:", typeof BluetoothService !== 'undefined')
Logger.log("Bluetooth", "Component loaded, bluetoothEnabled:", bluetoothEnabled)
Logger.log("Bluetooth", "BluetoothService available:", typeof BluetoothService !== 'undefined')
if (typeof BluetoothService !== 'undefined') {
console.log("[Bluetooth] Connected devices:", BluetoothService.connectedDevices.length)
Logger.log("Bluetooth", "Connected devices:", BluetoothService.connectedDevices.length)
}
}
icon: {
@ -55,4 +55,4 @@ NIconButton {
BluetoothMenu {
id: bluetoothMenuLoader
}
}
}

View file

@ -214,34 +214,34 @@ NLoader {
// Combine all devices into a single list for the ListView
property var allDevices: {
const devices = []
// Add connected devices first
for (const device of BluetoothService.connectedDevices) {
devices.push({
device: device,
type: 'connected',
section: 'Connected Devices'
})
"device": device,
"type": 'connected',
"section": 'Connected Devices'
})
}
// Add paired devices
for (const device of BluetoothService.pairedDevices) {
devices.push({
device: device,
type: 'paired',
section: 'Paired Devices'
})
"device": device,
"type": 'paired',
"section": 'Paired Devices'
})
}
// Add available devices
for (const device of BluetoothService.availableDevices) {
devices.push({
device: device,
type: 'available',
section: 'Available Devices'
})
"device": device,
"type": 'available',
"section": 'Available Devices'
})
}
return devices
}
@ -362,9 +362,8 @@ NLoader {
// Empty state when no devices found
ColumnLayout {
anchors.centerIn: parent
visible: Settings.data.network.bluetoothEnabled &&
!BluetoothService.isDiscovering &&
deviceList.count === 0
visible: Settings.data.network.bluetoothEnabled && !BluetoothService.isDiscovering
&& deviceList.count === 0
spacing: Style.marginMedium * scaling
NText {
@ -394,4 +393,4 @@ NLoader {
}
}
}
}
}

View file

@ -100,7 +100,7 @@ Item {
trayPanel.show()
} else {
console.log("[Tray] no menu available for", modelData.id, "or trayMenu not set")
Logger.log("Tray", "No menu available for", modelData.id, "or trayMenu not set")
}
}
}

View file

@ -44,7 +44,7 @@ PopupWindow {
function showAt(item, x, y) {
if (!item) {
console.warn("CustomTrayMenu: anchorItem is undefined, won't show menu.")
Logger.warn("TrayMenu", "anchorItem is undefined, won't show menu.")
return
}
anchorItem = item
@ -267,7 +267,7 @@ PopupWindow {
function showAt(item, x, y) {
if (!item) {
console.warn("subMenuComponent: anchorItem is undefined, not showing menu.")
Logger.warn("TrayMenu", "SubComponent anchorItem is undefined, not showing menu.")
return
}
anchorItem = item

View file

@ -26,7 +26,7 @@ Item {
Connections {
target: AudioService.sink?.audio ? AudioService.sink?.audio : null
function onVolumeChanged() {
// console.log("[Bar:Volume] onVolumeChanged")
// Logger.log("Bar:Volume", "onVolumeChanged")
if (!firstVolumeReceived) {
// Ignore the first volume change
firstVolumeReceived = true

View file

@ -145,8 +145,6 @@ NLoader {
Layout.fillWidth: true
}
NIconButton {
icon: "refresh"
tooltipText: "Refresh Networks"

View file

@ -202,7 +202,7 @@ NLoader {
label: "Label"
description: "Description"
onToggled: checked => {
console.log("[DemoPanel] NToggle:", checked)
Logger.log("DemoPanel", "NToggle:", checked)
}
}
@ -255,7 +255,7 @@ NLoader {
}
currentKey: "dog"
onSelected: function (key) {
console.log("[DemoPanel] NComboBox: selected ", key)
Logger.log("DemoPanel", "NComboBox: selected ", key)
}
}

View file

@ -197,7 +197,7 @@ NLoader {
color: appButton.hovered ? Colors.mSurfaceVariant : "transparent"
radius: parent.radius
opacity: appButton.hovered ? 0.8 : 0
Behavior on opacity {
NumberAnimation {
duration: Style.animationFast
@ -218,9 +218,9 @@ NLoader {
mipmap: false
antialiasing: false
fillMode: Image.PreserveAspectFit
scale: appButton.hovered ? 1.1 : 1.0
Behavior on scale {
NumberAnimation {
duration: Style.animationFast
@ -237,9 +237,9 @@ NLoader {
font.family: "Material Symbols Rounded"
font.pointSize: iconSize * 0.7 * scaling
color: appButton.isActive ? Colors.mPrimary : Colors.mOnSurfaceVariant
scale: appButton.hovered ? 1.1 : 1.0
Behavior on scale {
NumberAnimation {
duration: Style.animationFast

View file

@ -24,39 +24,39 @@ WlSessionLock {
locked: false
function unlockAttempt() {
console.log("Unlock attempt started")
Logger.log("LockScreen", "Unlock attempt started")
// Real PAM authentication
if (!pamAvailable) {
lock.errorMessage = "PAM authentication not available."
console.log("PAM not available")
Logger.log("LockScreen", "PAM not available")
return
}
if (!lock.password) {
lock.errorMessage = "Password required."
console.log("No password entered")
Logger.log("LockScreen", "No password entered")
return
}
console.log("Starting PAM authentication...")
Logger.log("LockScreen", "Starting PAM authentication")
lock.authenticating = true
lock.errorMessage = ""
console.log("[LockScreen] About to create PAM context with userName:", Quickshell.env("USER"))
Logger.log("LockScreen", "About to create PAM context with userName:", Quickshell.env("USER"))
var pam = Qt.createQmlObject(
'import Quickshell.Services.Pam; PamContext { config: "login"; user: "' + Quickshell.env("USER") + '" }',
lock)
console.log("PamContext created", pam)
Logger.log("LockScreen", "PamContext created", pam)
pam.onCompleted.connect(function (result) {
console.log("PAM completed with result:", result)
Logger.log("LockScreen", "PAM completed with result:", result)
lock.authenticating = false
if (result === PamResult.Success) {
console.log("Authentication successful, unlocking...")
Logger.log("LockScreen", "Authentication successful, unlocking")
lock.locked = false
lock.password = ""
lock.errorMessage = ""
} else {
console.log("Authentication failed")
Logger.log("LockScreen", "Authentication failed")
lock.errorMessage = "Authentication failed."
lock.password = ""
}
@ -64,7 +64,7 @@ WlSessionLock {
})
pam.onError.connect(function (error) {
console.log("PAM error:", error)
Logger.log("LockScreen", "PAM error:", error)
lock.authenticating = false
lock.errorMessage = pam.message || "Authentication error."
lock.password = ""
@ -72,22 +72,22 @@ WlSessionLock {
})
pam.onPamMessage.connect(function () {
console.log("PAM message:", pam.message, "isError:", pam.messageIsError)
Logger.log("LockScreen", "PAM message:", pam.message, "isError:", pam.messageIsError)
if (pam.messageIsError) {
lock.errorMessage = pam.message
}
})
pam.onResponseRequiredChanged.connect(function () {
console.log("PAM response required:", pam.responseRequired)
Logger.log("LockScreen", "PAM response required:", pam.responseRequired)
if (pam.responseRequired && lock.authenticating) {
console.log("Responding to PAM with password")
Logger.log("LockScreen", "Responding to PAM with password")
pam.respond(lock.password)
}
})
var started = pam.start()
console.log("PAM start result:", started)
Logger.log("LockScreen", "PAM start result:", started)
}
WlSessionLockSurface {

View file

@ -248,7 +248,7 @@ NLoader {
sizeMultiplier: 0.7
onClicked: {
console.log("[NotificationHistory] Removing notification:", summary)
Logger.log("NotificationHistory", "Removing notification:", summary)
NotificationService.historyModel.remove(index)
NotificationService.saveHistory()
}

View file

@ -58,8 +58,8 @@ Item {
description: "Display the brightness control icon in the top bar"
checked: !Settings.data.bar.hideBrightness
onToggled: checked => {
Settings.data.bar.hideBrightness = !checked
}
Settings.data.bar.hideBrightness = !checked
}
}
}
@ -168,7 +168,9 @@ Item {
color: Colors.mSecondary
}
Item { Layout.fillWidth: true }
Item {
Layout.fillWidth: true
}
NText {
text: BrightnessService.currentMethod === "ddcutil" ? "External (DDC)" : "Internal"
@ -228,7 +230,9 @@ Item {
Layout.alignment: Qt.AlignLeft
}
Item { Layout.fillWidth: true }
Item {
Layout.fillWidth: true
}
NText {
text: BrightnessService.available ? "Available" : "Unavailable"
@ -247,4 +251,4 @@ Item {
}
}
}
}
}

View file

@ -92,7 +92,7 @@ ColumnLayout {
var jsonData = JSON.parse(text())
root.schemeLoaded(schemeName, jsonData)
} catch (e) {
console.warn("Failed to parse JSON for scheme:", schemeName, e)
Logger.warn("Failed to parse JSON for scheme:", schemeName, e)
root.schemeLoaded(schemeName, null) // Load defaults on parse error
}
}

View file

@ -18,7 +18,7 @@ NBox {
// Height can be overridden by parent layout (SidePanel binds it to stats card)
//implicitHeight: content.implicitHeight + Style.marginLarge * 2 * scaling
// Component.onCompleted: {
// console.log(MediaService.trackArtUrl)
// Logger.logMediaService.trackArtUrl)
// }
ColumnLayout {
anchors.fill: parent

View file

@ -103,7 +103,7 @@ NPanel {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
console.log("Lock screen requested")
Logger.log("PowerMenu", "Lock screen requested")
// Lock the screen
lockScreen.locked = true
powerMenu.visible = false
@ -353,7 +353,7 @@ NPanel {
} else if (WorkspacesService.isHyprland) {
logoutProcessHyprland.running = true
} else {
console.warn("No supported compositor detected for logout")
Logger.warn("PowerMenu", "No supported compositor detected for logout")
}
}