Skip to content

Commit

Permalink
Put logging string in closure (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Sep 27, 2024
1 parent 85d7841 commit 2aa73ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
15 changes: 7 additions & 8 deletions Sources/AppState/Application/Application+public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 7 additions & 9 deletions Sources/AppState/PropertyWrappers/State/SecureState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2aa73ed

Please sign in to comment.