From 3bcb60a09ae73212bca8b51ab56bdd1aebeb2f19 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Mon, 2 Feb 2026 18:16:18 -0500 Subject: [PATCH] logging --- allstarr/Program.cs | 8 ----- .../Spotify/SpotifyMissingTracksFetcher.cs | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/allstarr/Program.cs b/allstarr/Program.cs index 3549b1e..7541ca3 100644 --- a/allstarr/Program.cs +++ b/allstarr/Program.cs @@ -16,14 +16,6 @@ using System.Text; var builder = WebApplication.CreateBuilder(args); -// Configure logging with timestamps -builder.Logging.ClearProviders(); -builder.Logging.AddSimpleConsole(options => -{ - options.TimestampFormat = "[yyyy-MM-dd HH:mm:ss.fff] "; - options.SingleLine = false; -}); - // Decode SquidWTF API base URLs once at startup var squidWtfApiUrls = DecodeSquidWtfUrls(); static List DecodeSquidWtfUrls() diff --git a/allstarr/Services/Spotify/SpotifyMissingTracksFetcher.cs b/allstarr/Services/Spotify/SpotifyMissingTracksFetcher.cs index 6ddc5e5..411b634 100644 --- a/allstarr/Services/Spotify/SpotifyMissingTracksFetcher.cs +++ b/allstarr/Services/Spotify/SpotifyMissingTracksFetcher.cs @@ -354,11 +354,22 @@ public class SpotifyMissingTracksFetcher : BackgroundService // First search forward 24 hours (most likely to find newest files with timezone ahead) _logger.LogInformation(" Phase 1: Searching forward 24 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...", now.AddMinutes(1), now.AddMinutes(1440)); + + var lastLoggedMinute = -1; for (var minutesAhead = 1; minutesAhead <= 1440; minutesAhead++) { if (cancellationToken.IsCancellationRequested) break; var time = now.AddMinutes(minutesAhead); + + // Log every 10 minutes to show progress with actual filename + if (minutesAhead % 10 == 0 && minutesAhead != lastLoggedMinute) + { + var sampleFilename = $"{playlistName}_missing_{time:yyyy-MM-dd_HH-mm}.json"; + _logger.LogInformation(" Checking around: {Filename}", sampleFilename); + lastLoggedMinute = minutesAhead; + } + var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken); if (result.found) { @@ -384,11 +395,22 @@ public class SpotifyMissingTracksFetcher : BackgroundService { _logger.LogInformation(" Phase 2: Searching backward 48 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...", now, now.AddMinutes(-2880)); + + lastLoggedMinute = -1; for (var minutesBehind = 0; minutesBehind <= 2880; minutesBehind++) { if (cancellationToken.IsCancellationRequested) break; var time = now.AddMinutes(-minutesBehind); + + // Log every 10 minutes to show progress with actual filename + if (minutesBehind % 10 == 0 && minutesBehind != lastLoggedMinute) + { + var sampleFilename = $"{playlistName}_missing_{time:yyyy-MM-dd_HH-mm}.json"; + _logger.LogInformation(" Checking around: {Filename}", sampleFilename); + lastLoggedMinute = minutesBehind; + } + var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken); if (result.found) { @@ -466,13 +488,7 @@ public class SpotifyMissingTracksFetcher : BackgroundService try { - // Log first and last attempts in each phase - var minuteDiff = (time - DateTime.UtcNow).TotalMinutes; - if (Math.Abs(minuteDiff - 1) < 0.1 || Math.Abs(minuteDiff - 1440) < 0.1 || - Math.Abs(minuteDiff) < 0.1 || Math.Abs(minuteDiff + 2880) < 0.1) - { - _logger.LogDebug(" Trying: {Filename} ({Time:yyyy-MM-dd HH:mm} UTC)", filename, time); - } + _logger.LogDebug("Checking: {Filename}", filename); var response = await httpClient.GetAsync(url, cancellationToken); if (response.IsSuccessStatusCode)