From 8277a9edcd36100d5f2c08878e351c726e77b851 Mon Sep 17 00:00:00 2001 From: Casper Sparre Date: Fri, 20 Feb 2026 23:26:45 +0100 Subject: [PATCH] Tweaked console outputs and some logging --- .../CLI/CajetanDownloadEventHandler.cs | 2 +- Cajetan.OF-DL/Worker.cs | 34 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Cajetan.OF-DL/CLI/CajetanDownloadEventHandler.cs b/Cajetan.OF-DL/CLI/CajetanDownloadEventHandler.cs index 90c24f3..946dac4 100644 --- a/Cajetan.OF-DL/CLI/CajetanDownloadEventHandler.cs +++ b/Cajetan.OF-DL/CLI/CajetanDownloadEventHandler.cs @@ -21,7 +21,7 @@ public class CajetanDownloadEventHandler : ICajetanDownloadEventHandler => _eventHandler.OnMessage(message); public void OnMessage(string message, string color) - => AnsiConsole.Markup($"[{color.ToLowerInvariant()}]{Markup.Escape(message)}\n[/]"); + => AnsiConsole.MarkupLine($"[{color.ToLowerInvariant()}]{Markup.Escape(message)}[/]"); public void OnNoContentFound(string contentType) => _eventHandler.OnNoContentFound(contentType); diff --git a/Cajetan.OF-DL/Worker.cs b/Cajetan.OF-DL/Worker.cs index 3ac72be..313d717 100644 --- a/Cajetan.OF-DL/Worker.cs +++ b/Cajetan.OF-DL/Worker.cs @@ -152,7 +152,11 @@ internal class Worker(IServiceProvider serviceProvider) LoggerWithConfigContext(_configService.CurrentConfig, _cajetanConfig) .Information("Scraping Data for {UserCount} user(s)", usersToDownload.Count); - eventHandler.OnMessage($"Scraping Data for {usersToDownload.Count} user(s)\n"); + + eventHandler.OnMessage( + $"\nScraping Data for {usersToDownload.Count} user(s)\n" + + $"{"======================================================================================================"}\n" + ); foreach ((string username, long userId) in usersToDownload) { @@ -182,17 +186,19 @@ internal class Worker(IServiceProvider serviceProvider) DateTime userEndTime = DateTime.Now; TimeSpan userTotalTime = userEndTime - userStartTime; - Log.ForContext("Paid Posts", newResults.PaidPostCount) - .ForContext("Posts", newResults.PostCount) + Log.ForContext("Posts", newResults.PostCount) + .ForContext("PaidPosts", newResults.PaidPostCount) + .ForContext("AllPosts", newResults.PostCount + newResults.PaidPostCount) .ForContext("Archived", newResults.ArchivedCount) .ForContext("Streams", newResults.StreamsCount) .ForContext("Stories", newResults.StoriesCount) .ForContext("Highlights", newResults.HighlightsCount) .ForContext("Messages", newResults.MessagesCount) - .ForContext("Paid Messages", newResults.PaidMessagesCount) + .ForContext("PaidMessages", newResults.PaidMessagesCount) + .ForContext("AllMessages", newResults.MessagesCount + newResults.PaidMessagesCount) .ForContext("Username", username) .ForContext("TotalMinutes", userTotalTime.TotalMinutes) - .Information("Scraped Data for '{Username:l}', took {TotalMinutes:0.000} minutes"); + .Information("Scraped Data for '{Username:l}', took {TotalMinutes:0.000} minutes [P: {AllPosts}] [M: {AllMessages}]"); } catch (Exception ex) { @@ -209,16 +215,18 @@ internal class Worker(IServiceProvider serviceProvider) eventHandler.OnScrapeComplete(totalTime); - Log.ForContext("Paid Posts", totalResults.PaidPostCount) - .ForContext("Posts", totalResults.PostCount) + Log.ForContext("Posts", totalResults.PostCount) + .ForContext("PaidPosts", totalResults.PaidPostCount) + .ForContext("AllPosts", totalResults.PostCount + totalResults.PaidPostCount) .ForContext("Archived", totalResults.ArchivedCount) .ForContext("Streams", totalResults.StreamsCount) .ForContext("Stories", totalResults.StoriesCount) .ForContext("Highlights", totalResults.HighlightsCount) .ForContext("Messages", totalResults.MessagesCount) - .ForContext("Paid Messages", totalResults.PaidMessagesCount) + .ForContext("PaidMessages", totalResults.PaidMessagesCount) + .ForContext("AllMessages", totalResults.MessagesCount + totalResults.PaidMessagesCount) .ForContext("TotalMinutes", totalTime.TotalMinutes) - .Information("Scrape Completed in {TotalMinutes:0.00} minutes"); + .Information("Scrape Completed in {TotalMinutes:0.00} minutes [P: {AllPosts}] [M: {AllMessages}]"); await Task.Delay(2000); } @@ -322,7 +330,7 @@ internal class Worker(IServiceProvider serviceProvider) continue; Log.Information("Getting Users from list '{ListName:l}' (Include Restricted: {IncludeRestrictedSubscriptions})", name, currentConfig.IncludeRestrictedSubscriptions); - AnsiConsole.Markup($"[green]Getting Users from list '{name}' (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})\n[/]"); + AnsiConsole.MarkupLine($"[green]Getting Users from list '{name}' (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})[/]"); List listUsernames = await _apiService.GetListUsers($"/lists/{listId}/users") ?? []; @@ -373,7 +381,7 @@ internal class Worker(IServiceProvider serviceProvider) async Task FetchUsersAsync() { Log.Information("Getting Active Subscriptions (Include Restricted: {IncludeRestrictedSubscriptions})", currentConfig.IncludeRestrictedSubscriptions); - AnsiConsole.Markup($"[green]Getting Active Subscriptions (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})\n[/]"); + AnsiConsole.MarkupLine($"[green]Getting Active Subscriptions (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})[/]"); Dictionary? activeSubs = await _apiService.GetActiveSubscriptions("/subscriptions/subscribes", currentConfig.IncludeRestrictedSubscriptions); AddToResult(activeSubs); @@ -381,7 +389,7 @@ internal class Worker(IServiceProvider serviceProvider) if (currentConfig.IncludeExpiredSubscriptions) { Log.Information("Getting Expired Subscriptions (Include Restricted: {IncludeRestrictedSubscriptions})", currentConfig.IncludeRestrictedSubscriptions); - AnsiConsole.Markup($"[green]Getting Expired Subscriptions (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})\n[/]"); + AnsiConsole.MarkupLine($"[green]Getting Expired Subscriptions (Include Restricted: {currentConfig.IncludeRestrictedSubscriptions})[/]"); Dictionary? expiredSubs = await _apiService.GetExpiredSubscriptions("/subscriptions/subscribes", currentConfig.IncludeRestrictedSubscriptions); AddToResult(expiredSubs); @@ -410,7 +418,7 @@ internal class Worker(IServiceProvider serviceProvider) Dictionary usersInNonNudeLists = await GetUsersFromSpecificListsAsync(result, [.. listNames]); - AnsiConsole.Markup($"[green]Updating Non-Nude collection with {usersInNonNudeLists.Count} Users[/]"); + AnsiConsole.MarkupLine($"[grey]Updating Non-Nude collection with {usersInNonNudeLists.Count} Users[/]"); await _dbService.UpdateNonNudeCollectionAsync(usersInNonNudeLists); AnsiConsole.WriteLine();