mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
logging
This commit is contained in:
@@ -16,14 +16,6 @@ using System.Text;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
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
|
// Decode SquidWTF API base URLs once at startup
|
||||||
var squidWtfApiUrls = DecodeSquidWtfUrls();
|
var squidWtfApiUrls = DecodeSquidWtfUrls();
|
||||||
static List<string> DecodeSquidWtfUrls()
|
static List<string> DecodeSquidWtfUrls()
|
||||||
|
|||||||
@@ -354,11 +354,22 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
|||||||
// First search forward 24 hours (most likely to find newest files with timezone ahead)
|
// 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)...",
|
_logger.LogInformation(" Phase 1: Searching forward 24 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...",
|
||||||
now.AddMinutes(1), now.AddMinutes(1440));
|
now.AddMinutes(1), now.AddMinutes(1440));
|
||||||
|
|
||||||
|
var lastLoggedMinute = -1;
|
||||||
for (var minutesAhead = 1; minutesAhead <= 1440; minutesAhead++)
|
for (var minutesAhead = 1; minutesAhead <= 1440; minutesAhead++)
|
||||||
{
|
{
|
||||||
if (cancellationToken.IsCancellationRequested) break;
|
if (cancellationToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
var time = now.AddMinutes(minutesAhead);
|
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);
|
var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken);
|
||||||
if (result.found)
|
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)...",
|
_logger.LogInformation(" Phase 2: Searching backward 48 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...",
|
||||||
now, now.AddMinutes(-2880));
|
now, now.AddMinutes(-2880));
|
||||||
|
|
||||||
|
lastLoggedMinute = -1;
|
||||||
for (var minutesBehind = 0; minutesBehind <= 2880; minutesBehind++)
|
for (var minutesBehind = 0; minutesBehind <= 2880; minutesBehind++)
|
||||||
{
|
{
|
||||||
if (cancellationToken.IsCancellationRequested) break;
|
if (cancellationToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
var time = now.AddMinutes(-minutesBehind);
|
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);
|
var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken);
|
||||||
if (result.found)
|
if (result.found)
|
||||||
{
|
{
|
||||||
@@ -466,13 +488,7 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Log first and last attempts in each phase
|
_logger.LogDebug("Checking: {Filename}", filename);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
var response = await httpClient.GetAsync(url, cancellationToken);
|
var response = await httpClient.GetAsync(url, cancellationToken);
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
|
|||||||
Reference in New Issue
Block a user