Improve logging: clarify search vs manual mappings, show manual mapping counts in final log

This commit is contained in:
2026-02-05 11:38:26 -05:00
parent 2153a24c86
commit 629e95ac30

View File

@@ -483,7 +483,7 @@ public class SpotifyTrackMatchingService : BackgroundService
await _cache.SetAsync(legacyKey, legacySongs, TimeSpan.FromHours(1)); await _cache.SetAsync(legacyKey, legacySongs, TimeSpan.FromHours(1));
_logger.LogInformation( _logger.LogInformation(
"✓ Cached {Matched}/{Total} tracks for {Playlist} (ISRC: {Isrc}, Fuzzy: {Fuzzy}, No match: {NoMatch})", "✓ Cached {Matched}/{Total} tracks for {Playlist} via search (ISRC: {Isrc}, Fuzzy: {Fuzzy}, No match: {NoMatch}) - manual mappings will be applied next",
matchedTracks.Count, tracksToMatch.Count, playlistName, isrcMatches, fuzzyMatches, noMatch); matchedTracks.Count, tracksToMatch.Count, playlistName, isrcMatches, fuzzyMatches, noMatch);
// Pre-build playlist items cache for instant serving // Pre-build playlist items cache for instant serving
@@ -805,6 +805,8 @@ public class SpotifyTrackMatchingService : BackgroundService
var usedJellyfinItems = new HashSet<string>(); var usedJellyfinItems = new HashSet<string>();
var localUsedCount = 0; var localUsedCount = 0;
var externalUsedCount = 0; var externalUsedCount = 0;
var manualLocalCount = 0;
var manualExternalCount = 0;
foreach (var spotifyTrack in spotifyTracks.OrderBy(t => t.Position)) foreach (var spotifyTrack in spotifyTracks.OrderBy(t => t.Position))
{ {
@@ -828,6 +830,7 @@ public class SpotifyTrackMatchingService : BackgroundService
if (itemStatusCode == 200 && itemResponse != null) if (itemStatusCode == 200 && itemResponse != null)
{ {
matchedJellyfinItem = itemResponse.RootElement; matchedJellyfinItem = itemResponse.RootElement;
manualLocalCount++;
_logger.LogDebug("✓ Using manual Jellyfin mapping for {Title}: Jellyfin ID {Id}", _logger.LogDebug("✓ Using manual Jellyfin mapping for {Title}: Jellyfin ID {Id}",
spotifyTrack.Title, manualJellyfinId); spotifyTrack.Title, manualJellyfinId);
} }
@@ -927,6 +930,7 @@ public class SpotifyTrackMatchingService : BackgroundService
var externalItem = responseBuilder.ConvertSongToJellyfinItem(externalSong); var externalItem = responseBuilder.ConvertSongToJellyfinItem(externalSong);
finalItems.Add(externalItem); finalItems.Add(externalItem);
externalUsedCount++; externalUsedCount++;
manualExternalCount++;
_logger.LogInformation("✓ Using manual external mapping for {Title}: {Provider} {ExternalId}", _logger.LogInformation("✓ Using manual external mapping for {Title}: {Provider} {ExternalId}",
spotifyTrack.Title, provider, externalId); spotifyTrack.Title, provider, externalId);
@@ -1007,9 +1011,15 @@ public class SpotifyTrackMatchingService : BackgroundService
// Save to file cache for persistence // Save to file cache for persistence
await SavePlaylistItemsToFileAsync(playlistName, finalItems); await SavePlaylistItemsToFileAsync(playlistName, finalItems);
var manualMappingInfo = "";
if (manualLocalCount > 0 || manualExternalCount > 0)
{
manualMappingInfo = $" [Manual: {manualLocalCount} local, {manualExternalCount} external]";
}
_logger.LogInformation( _logger.LogInformation(
"✅ Pre-built playlist cache for {Playlist}: {Total} tracks ({Local} LOCAL + {External} EXTERNAL)", "✅ Pre-built playlist cache for {Playlist}: {Total} tracks ({Local} LOCAL + {External} EXTERNAL){ManualInfo}",
playlistName, finalItems.Count, localUsedCount, externalUsedCount); playlistName, finalItems.Count, localUsedCount, externalUsedCount, manualMappingInfo);
} }
else else
{ {