From 96fefbc8005caaf02abf740cc98a160b5f8f56a8 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 9 Jun 2024 22:39:36 -0700 Subject: [PATCH] Add logging to PostponingBlock. --- Core/Sources/Core/PostponingBlock.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/Sources/Core/PostponingBlock.swift b/Core/Sources/Core/PostponingBlock.swift index 35b881591..33befbace 100644 --- a/Core/Sources/Core/PostponingBlock.swift +++ b/Core/Sources/Core/PostponingBlock.swift @@ -6,6 +6,7 @@ // import Foundation +import os /// Runs a block of code in the future. Each time `runInFuture` is called, the block is postponed again until the future by `delayInterval`. @MainActor public final class PostponingBlock { @@ -15,6 +16,8 @@ import Foundation private let name: String // For debugging private var timer: Timer? + private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PostponingBlock") + public init(delayInterval: TimeInterval, name: String, block: @escaping () -> Void) { self.delayInterval = delayInterval @@ -47,6 +50,7 @@ private extension PostponingBlock { if let timer, timer.isValid { timer.invalidate() + logger.info("Canceling existing timer in PostponingBlock: \(self.name)") } timer = nil }