From 4134b41be227d4947fed7c89dc4f2d48984f9e9c Mon Sep 17 00:00:00 2001 From: Ilyas Hallak Date: Sat, 8 Nov 2025 19:18:56 +0100 Subject: [PATCH] Fix tag scrolling and improve debug logging - Fix duplicate ID warning in CoreDataTagManagementView by using objectID - Enhance debug logging system with category filtering --- .../CoreDataTagManagementView.swift | 2 +- readeck/Utils/Logger.swift | 33 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/readeck/UI/Components/CoreDataTagManagementView.swift b/readeck/UI/Components/CoreDataTagManagementView.swift index b3fd97d..24f630b 100644 --- a/readeck/UI/Components/CoreDataTagManagementView.swift +++ b/readeck/UI/Components/CoreDataTagManagementView.swift @@ -174,7 +174,7 @@ struct CoreDataTagManagementView: View { alignment: .top, spacing: 8 ) { - ForEach(tagEntities) { entity in + ForEach(tagEntities, id: \.objectID) { entity in if let name = entity.name, shouldShowTag(name) { UnifiedLabelChip( label: name, diff --git a/readeck/Utils/Logger.swift b/readeck/Utils/Logger.swift index 9f1feb1..16873af 100644 --- a/readeck/Utils/Logger.swift +++ b/readeck/Utils/Logger.swift @@ -52,6 +52,19 @@ class LogConfiguration: ObservableObject { @Published var isLoggingEnabled = false private init() { + // First time setup: Enable logging in DEBUG builds with sensible defaults + #if DEBUG + if UserDefaults.standard.object(forKey: "LogConfigurationInitialized") == nil { + isLoggingEnabled = true + showPerformanceLogs = true + showTimestamps = true + includeSourceLocation = true + globalMinLevel = .debug + UserDefaults.standard.set(true, forKey: "LogConfigurationInitialized") + saveConfiguration() + } + #endif + loadConfiguration() } @@ -81,12 +94,22 @@ class LogConfiguration: ObservableObject { } } } - + globalMinLevel = LogLevel(rawValue: UserDefaults.standard.integer(forKey: "LogGlobalLevel")) ?? .debug - showPerformanceLogs = UserDefaults.standard.bool(forKey: "LogShowPerformance") - showTimestamps = UserDefaults.standard.bool(forKey: "LogShowTimestamps") - includeSourceLocation = UserDefaults.standard.bool(forKey: "LogIncludeSourceLocation") - isLoggingEnabled = UserDefaults.standard.bool(forKey: "LogIsEnabled") + + // Load boolean settings with defaults + if UserDefaults.standard.object(forKey: "LogShowPerformance") != nil { + showPerformanceLogs = UserDefaults.standard.bool(forKey: "LogShowPerformance") + } + if UserDefaults.standard.object(forKey: "LogShowTimestamps") != nil { + showTimestamps = UserDefaults.standard.bool(forKey: "LogShowTimestamps") + } + if UserDefaults.standard.object(forKey: "LogIncludeSourceLocation") != nil { + includeSourceLocation = UserDefaults.standard.bool(forKey: "LogIncludeSourceLocation") + } + if UserDefaults.standard.object(forKey: "LogIsEnabled") != nil { + isLoggingEnabled = UserDefaults.standard.bool(forKey: "LogIsEnabled") + } } private func saveConfiguration() {