Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvOS not logging on real device #172

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/Pulse/Helpers/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 7 additions & 4 deletions Sources/Pulse/LoggerStore/LoggerStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down