From 2aa73eda4023340025418b4ad5f4790eab2b8c65 Mon Sep 17 00:00:00 2001 From: Zach Date: Fri, 27 Sep 2024 15:30:50 -0600 Subject: [PATCH] Put logging string in closure (#106) --- .../Application/Application+public.swift | 15 +++++++-------- .../PropertyWrappers/State/SecureState.swift | 16 +++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Sources/AppState/Application/Application+public.swift b/Sources/AppState/Application/Application+public.swift index f47765a..aa3d95a 100644 --- a/Sources/AppState/Application/Application+public.swift +++ b/Sources/AppState/Application/Application+public.swift @@ -673,16 +673,15 @@ public extension Application { _ column: Int = #column ) -> SecureState { let secureState = shared.value(keyPath: keyPath) - let debugMessage: String - - #if DEBUG - debugMessage = "🔑 Getting SecureState \(String(describing: keyPath)) -> \(secureState.value ?? "nil")" - #else - debugMessage = "🔑 Getting SecureState \(String(describing: keyPath))" - #endif log( - debug: debugMessage, + debug: { + #if DEBUG + "🔑 Getting SecureState \(String(describing: keyPath)) -> \(secureState.value ?? "nil")" + #else + "🔑 Getting SecureState \(String(describing: keyPath))" + #endif + }, fileID: fileID, function: function, line: line, diff --git a/Sources/AppState/PropertyWrappers/State/SecureState.swift b/Sources/AppState/PropertyWrappers/State/SecureState.swift index fa1d7f8..93997c7 100644 --- a/Sources/AppState/PropertyWrappers/State/SecureState.swift +++ b/Sources/AppState/PropertyWrappers/State/SecureState.swift @@ -38,16 +38,14 @@ import SwiftUI ).value } nonmutating set { - let debugMessage: String - - #if DEBUG - debugMessage = "🔑 Setting SecureState \(String(describing: keyPath)) = \(newValue ?? "nil")" - #else - debugMessage = "🔑 Setting SecureState \(String(describing: keyPath))" - #endif - Application.log( - debug: debugMessage, + debug: { + #if DEBUG + "🔑 Setting SecureState \(String(describing: keyPath)) = \(newValue ?? "nil")" + #else + "🔑 Setting SecureState \(String(describing: keyPath))" + #endif + }, fileID: fileID, function: function, line: line,