diff --git a/Sources/Pulse/Helpers/Extensions.swift b/Sources/Pulse/Helpers/Extensions.swift index 27e41e81e..26870154d 100644 --- a/Sources/Pulse/Helpers/Extensions.swift +++ b/Sources/Pulse/Helpers/Extensions.swift @@ -34,7 +34,13 @@ extension URL { } static var logs: URL { - var url = Files.urls(for: .libraryDirectory, in: .userDomainMask).first? + var searchPath = FileManager.SearchPathDirectory.documentDirectory + + #if os(tvOS) + searchPath = .cachesDirectory + #endif + + var url = Files.urls(for: searchPath, in: .userDomainMask).first? .appending(directory: "Logs") .appending(directory: "com.github.kean.logger") ?? URL(fileURLWithPath: "/dev/null") if !Files.createDirectoryIfNeeded(at: url) { diff --git a/Sources/Pulse/LoggerStore/LoggerStore.swift b/Sources/Pulse/LoggerStore/LoggerStore.swift index 59fcbffe4..dda56520a 100644 --- a/Sources/Pulse/LoggerStore/LoggerStore.swift +++ b/Sources/Pulse/LoggerStore/LoggerStore.swift @@ -70,11 +70,14 @@ public final class LoggerStore: @unchecked Sendable { private static func makeDefault() -> LoggerStore { let storeURL = URL.logs.appending(directory: "current.pulse") - guard let store = try? LoggerStore(storeURL: storeURL, options: [.create, .sweep]) else { - return LoggerStore(inMemoryStore: storeURL) // Right side should never happen + if let store = try? LoggerStore(storeURL: storeURL, options: [.create, .sweep]) { + register(store: store) + return store + } else { + let memoryStore = LoggerStore(inMemoryStore: storeURL) // Right side should never happen + register(store: memoryStore) + return memoryStore } - register(store: store) - return store } // MARK: Initialization