Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Preserve readable Cast error logs

Manav Rathib929f9143b18
diff --git a/apple/apps/cast/Cast/CastApp.swift b/apple/apps/cast/Cast/CastApp.swift
index 0b79b3fc1e..d84f950958 100644
--- a/apple/apps/cast/Cast/CastApp.swift
+++ b/apple/apps/cast/Cast/CastApp.swift
@@ -20,11 +20,11 @@ private final class CastRustLogSink: RustLogSink, @unchecked Sendable {
func log(level: RustLogLevel, target: String, message: String) {
switch level {
case .error:
- logger.error("[\(target)] \(message)")
+ logger.error("[\(target, privacy: .public)] \(message, privacy: .public)")
case .warn:
- logger.warning("[\(target)] \(message)")
+ logger.warning("[\(target, privacy: .public)] \(message, privacy: .public)")
case .info:
- logger.info("[\(target)] \(message)")
+ logger.info("[\(target, privacy: .public)] \(message, privacy: .public)")
}
}
}
diff --git a/apple/apps/cast/Cast/ViewModels/CastViewModel.swift b/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
index 1b669ca2ad..6d881e1815 100644
--- a/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
+++ b/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
@@ -294,7 +294,6 @@ class CastViewModel: ObservableObject {
}
private func handleError(_ message: String) {
- logger.error("Cast session failed: \(message)")
currentView = .error
errorMessage = message
statusMessage = ""
@@ -302,6 +301,7 @@ class CastViewModel: ObservableObject {
}
private func handleNetworkError(_ error: Error) {
+ logger.error("Cast session failed: \(error.localizedDescription, privacy: .public)")
handleError("An error occurred: \(error.localizedDescription)")
let sessionID = sessionID
diff --git a/apple/apps/cast/Cast/ViewModels/SlideshowService.swift b/apple/apps/cast/Cast/ViewModels/SlideshowService.swift
index f7f44686d0..2fbe9b1913 100644
--- a/apple/apps/cast/Cast/ViewModels/SlideshowService.swift
+++ b/apple/apps/cast/Cast/ViewModels/SlideshowService.swift
@@ -176,7 +176,8 @@ class RealSlideshowService: ObservableObject {
logger.info("Slideshow started with \(fileCount) slides")
} catch {
- logger.error("Failed to start slideshow: \(error.localizedDescription)")
+ logger.error(
+ "Failed to start slideshow: \(error.localizedDescription, privacy: .public)")
await MainActor.run {
self.error = "Failed to load slideshow: \(error.localizedDescription)"
}
@@ -253,7 +254,7 @@ class RealSlideshowService: ObservableObject {
}
} catch {
guard storedCastPayload == castPayload else { return }
- logger.error("Failed to fetch files: \(error.localizedDescription)")
+ logger.error("Failed to fetch files: \(error.localizedDescription, privacy: .public)")
hasCompletedInitialFetch = false
self.error = "Failed to load files: \(error.localizedDescription)"
}
@@ -406,7 +407,9 @@ class RealSlideshowService: ObservableObject {
}
}
} catch {
- logger.error("Failed to process file metadata: \(error.localizedDescription)")
+ logger.error(
+ "Failed to process file metadata: \(error.localizedDescription, privacy: .public)"
+ )
}
}
}
@@ -503,7 +506,8 @@ class RealSlideshowService: ObservableObject {
} catch {
guard storedCastPayload == payload else { return }
- logger.error("Failed to load slideshow item: \(error.localizedDescription)")
+ logger.error(
+ "Failed to load slideshow item: \(error.localizedDescription, privacy: .public)")
await MainActor.run {
slideLoadingProgress = 0.0
@@ -547,7 +551,8 @@ class RealSlideshowService: ObservableObject {
} catch {
logger.error(
- "Failed to extract Live Photo components: \(error.localizedDescription)")
+ "Failed to extract Live Photo components: \(error.localizedDescription, privacy: .public)"
+ )
currentImageData = data
currentVideoData = nil
currentVideoURL = nil
@@ -578,7 +583,9 @@ class RealSlideshowService: ObservableObject {
currentVideoData = nil
prepareVideoPlayer(url: url)
} catch {
- logger.error("Failed to save temporary video file: \(error.localizedDescription)")
+ logger.error(
+ "Failed to save temporary video file: \(error.localizedDescription, privacy: .public)"
+ )
currentVideoURL = nil
}
} else {
@@ -658,7 +665,9 @@ class RealSlideshowService: ObservableObject {
} catch {
guard storedCastPayload == payload else { return }
- logger.error("Failed to load next slideshow item: \(error.localizedDescription)")
+ logger.error(
+ "Failed to load next slideshow item: \(error.localizedDescription, privacy: .public)"
+ )
currentFileIndex = (currentFileIndex + 1) % allFiles.count
retryCount += 1
}
@@ -824,7 +833,8 @@ class RealSlideshowService: ObservableObject {
{
// fetchFilesBatch already handled this error.
} else {
- logger.error("Periodic diff check failed: \(error.localizedDescription)")
+ logger.error(
+ "Periodic diff check failed: \(error.localizedDescription, privacy: .public)")
}
}
}
diff --git a/apple/apps/cast/Cast/Views/VideoPlayerView.swift b/apple/apps/cast/Cast/Views/VideoPlayerView.swift
index e38fa37717..b197b15fd4 100644
--- a/apple/apps/cast/Cast/Views/VideoPlayerView.swift
+++ b/apple/apps/cast/Cast/Views/VideoPlayerView.swift
@@ -92,7 +92,9 @@ struct VideoPlayerView: View {
tryVideoFallback(originalURL: tempURL)
}
} catch {
- logger.error("Failed to set up video player: \(error.localizedDescription)")
+ logger.error(
+ "Failed to set up video player: \(error.localizedDescription, privacy: .public)"
+ )
await MainActor.run {
showErrorState()
}
@@ -116,7 +118,8 @@ struct VideoPlayerView: View {
setupPlayer()
}
} catch {
- logger.error("Video fallback failed: \(error.localizedDescription)")
+ logger.error(
+ "Video fallback failed: \(error.localizedDescription, privacy: .public)")
showErrorState()
}
}
@@ -131,7 +134,8 @@ struct VideoPlayerView: View {
timer.invalidate()
case .failed:
if let error = playerItem.error {
- logger.error("Video player failed: \(error.localizedDescription)")
+ logger.error(
+ "Video player failed: \(error.localizedDescription, privacy: .public)")
}
timer.invalidate()
Task { @MainActor in
@@ -155,7 +159,8 @@ struct VideoPlayerView: View {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
- logger.error("Failed to set up audio session: \(error.localizedDescription)")
+ logger.error(
+ "Failed to set up audio session: \(error.localizedDescription, privacy: .public)")
}
setupPlayerObservers()
@@ -185,7 +190,8 @@ struct VideoPlayerView: View {
if let error = notification
.userInfo?[AVPlayerItemFailedToPlayToEndTimeErrorKey] as? Error
{
- logger.error("Video playback failed: \(error.localizedDescription)")
+ logger.error(
+ "Video playback failed: \(error.localizedDescription, privacy: .public)")
}
}
@@ -295,7 +301,9 @@ struct VideoPlayerView: View {
options: .notifyOthersOnDeactivation,
)
} catch {
- logger.error("Failed to deactivate audio session: \(error.localizedDescription)")
+ logger.error(
+ "Failed to deactivate audio session: \(error.localizedDescription, privacy: .public)"
+ )
}
player = nil