From c4b9d9503a76ec553dc898edc5b30246992eca3e Mon Sep 17 00:00:00 2001 From: Flaminel Date: Mon, 7 Jul 2025 14:28:15 +0300 Subject: [PATCH] Add more logs for debug (#201) --- .../Features/ContentBlocker/ContentBlocker.cs | 4 ++++ .../Features/QueueCleaner/QueueCleaner.cs | 4 ++++ .../Features/DownloadClient/Deluge/DelugeServiceCB.cs | 5 +++++ .../Features/DownloadClient/Deluge/DelugeServiceQC.cs | 10 +++++++--- .../DownloadClient/QBittorrent/QBitServiceCB.cs | 8 ++++++++ .../DownloadClient/QBittorrent/QBitServiceQC.cs | 8 ++++++++ .../Transmission/TransmissionServiceCB.cs | 7 ++++++- .../Transmission/TransmissionServiceQC.cs | 10 +++++++--- .../Features/ItemStriker/Striker.cs | 1 + 9 files changed, 50 insertions(+), 7 deletions(-) diff --git a/code/backend/Cleanuparr.Application/Features/ContentBlocker/ContentBlocker.cs b/code/backend/Cleanuparr.Application/Features/ContentBlocker/ContentBlocker.cs index 47e36f64..a95942e7 100644 --- a/code/backend/Cleanuparr.Application/Features/ContentBlocker/ContentBlocker.cs +++ b/code/backend/Cleanuparr.Application/Features/ContentBlocker/ContentBlocker.cs @@ -183,6 +183,10 @@ public sealed class ContentBlocker : GenericHandler _logger.LogWarning("Download not found in any torrent client | {title}", record.Title); } } + else + { + _logger.LogDebug("No torrent clients enabled"); + } } if (!result.ShouldRemove) diff --git a/code/backend/Cleanuparr.Application/Features/QueueCleaner/QueueCleaner.cs b/code/backend/Cleanuparr.Application/Features/QueueCleaner/QueueCleaner.cs index 44ab6367..23f108f8 100644 --- a/code/backend/Cleanuparr.Application/Features/QueueCleaner/QueueCleaner.cs +++ b/code/backend/Cleanuparr.Application/Features/QueueCleaner/QueueCleaner.cs @@ -141,6 +141,10 @@ public sealed class QueueCleaner : GenericHandler _logger.LogWarning("Download not found in any torrent client | {title}", record.Title); } } + else + { + _logger.LogDebug("No torrent clients enabled"); + } } var config = ContextProvider.Get(); diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceCB.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceCB.cs index a1967896..3d7b8075 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceCB.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceCB.cs @@ -77,6 +77,7 @@ public partial class DelugeService if (file.Priority is 0) { + _logger.LogTrace("File is already skipped | {file}", file.Path); totalUnwantedFiles++; } @@ -88,6 +89,7 @@ public partial class DelugeService _logger.LogInformation("unwanted file found | {file}", file.Path); } + _logger.LogTrace("File is valid | {file}", file.Path); priorities.Add(file.Index, priority); }); @@ -105,8 +107,11 @@ public partial class DelugeService if (totalUnwantedFiles == totalFiles) { + _logger.LogDebug("All files are blocked for {name}", download.Name); result.ShouldRemove = true; } + + _logger.LogDebug("Marking {count} unwanted files as skipped for {name}", totalUnwantedFiles, download.Name); await _dryRunInterceptor.InterceptAsync(ChangeFilesPriority, hash, sortedPriorities); diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceQC.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceQC.cs index 29c1a178..7df34167 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceQC.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Deluge/DelugeServiceQC.cs @@ -1,6 +1,4 @@ -using System.Collections.Concurrent; -using System.Text.RegularExpressions; -using Cleanuparr.Domain.Entities; +using Cleanuparr.Domain.Entities; using Cleanuparr.Domain.Entities.Deluge.Response; using Cleanuparr.Domain.Enums; using Cleanuparr.Infrastructure.Extensions; @@ -61,6 +59,7 @@ public partial class DelugeService if (shouldRemove) { // remove if all files are unwanted + _logger.LogTrace("all files are unwanted | removing download | {name}", download.Name); result.ShouldRemove = true; result.DeleteReason = DeleteReason.AllFilesSkipped; return result; @@ -95,11 +94,13 @@ public partial class DelugeService if (download.State is null || !download.State.Equals("Downloading", StringComparison.InvariantCultureIgnoreCase)) { + _logger.LogTrace("skip slow check | item is in {state} state | {name}", download.State, download.Name); return (false, DeleteReason.None); } if (download.DownloadSpeed <= 0) { + _logger.LogTrace("skip slow check | download speed is 0 | {name}", download.Name); return (false, DeleteReason.None); } @@ -137,6 +138,7 @@ public partial class DelugeService if (queueCleanerConfig.Stalled.MaxStrikes is 0) { + _logger.LogTrace("skip stalled check | max strikes is 0 | {name}", status.Name); return (false, DeleteReason.None); } @@ -149,11 +151,13 @@ public partial class DelugeService if (status.State is null || !status.State.Equals("Downloading", StringComparison.InvariantCultureIgnoreCase)) { + _logger.LogTrace("skip stalled check | download is in {state} state | {name}", status.State, status.Name); return (false, DeleteReason.None); } if (status.Eta > 0) { + _logger.LogTrace("skip stalled check | download is not stalled | {name}", status.Name); return (false, DeleteReason.None); } diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceCB.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceCB.cs index 72014f2d..60ed9675 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceCB.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceCB.cs @@ -62,6 +62,7 @@ public partial class QBitService if (files is null) { + _logger.LogDebug("torrent {hash} has no files", hash); return result; } @@ -78,6 +79,7 @@ public partial class QBitService { if (!file.Index.HasValue) { + _logger.LogTrace("Skipping file with no index | {file}", file.Name); continue; } @@ -85,12 +87,14 @@ public partial class QBitService if (file.Priority is TorrentContentPriority.Skip) { + _logger.LogTrace("File is already skipped | {file}", file.Name); totalUnwantedFiles++; continue; } if (_filenameEvaluator.IsValid(file.Name, blocklistType, patterns, regexes)) { + _logger.LogTrace("File is valid | {file}", file.Name); continue; } @@ -101,13 +105,17 @@ public partial class QBitService if (unwantedFiles.Count is 0) { + _logger.LogDebug("No unwanted files found for {name}", download.Name); return result; } if (totalUnwantedFiles == totalFiles) { + _logger.LogDebug("All files are blocked for {name}", download.Name); result.ShouldRemove = true; } + + _logger.LogDebug("Marking {count} unwanted files as skipped for {name}", totalUnwantedFiles, download.Name); foreach (int fileIndex in unwantedFiles) { diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceQC.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceQC.cs index 4f08b66e..a7e094ed 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceQC.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/QBittorrent/QBitServiceQC.cs @@ -55,11 +55,13 @@ public partial class QBitService // if all files were blocked by qBittorrent if (download is { CompletionOn: not null, Downloaded: null or 0 }) { + _logger.LogDebug("all files are unwanted by qBit | removing download | {name}", download.Name); result.DeleteReason = DeleteReason.AllFilesSkippedByQBit; return result; } // remove if all files are unwanted + _logger.LogDebug("all files are unwanted | removing download | {name}", download.Name); result.DeleteReason = DeleteReason.AllFilesSkipped; return result; } @@ -87,16 +89,19 @@ public partial class QBitService if (queueCleanerConfig.Slow.MaxStrikes is 0) { + _logger.LogDebug("skip slow check | max strikes is 0 | {name}", download.Name); return (false, DeleteReason.None); } if (download.State is not (TorrentState.Downloading or TorrentState.ForcedDownload)) { + _logger.LogDebug("skip slow check | download is in {state} state | {name}", download.State, download.Name); return (false, DeleteReason.None); } if (download.DownloadSpeed <= 0) { + _logger.LogDebug("skip slow check | download speed is 0 | {name}", download.Name); return (false, DeleteReason.None); } @@ -134,6 +139,7 @@ public partial class QBitService if (queueCleanerConfig.Stalled.MaxStrikes is 0 && queueCleanerConfig.Stalled.DownloadingMetadataMaxStrikes is 0) { + _logger.LogDebug("skip stalled check | max strikes is 0 | {name}", torrent.Name); return (false, DeleteReason.None); } @@ -141,6 +147,7 @@ public partial class QBitService and not TorrentState.ForcedFetchingMetadata) { // ignore other states + _logger.LogDebug("skip stalled check | download is in {state} state | {name}", torrent.State, torrent.Name); return (false, DeleteReason.None); } @@ -168,6 +175,7 @@ public partial class QBitService StrikeType.DownloadingMetadata), DeleteReason.DownloadingMetadata); } + _logger.LogDebug("skip stalled check | download is not stalled | {name}", torrent.Name); return (false, DeleteReason.None); } } \ No newline at end of file diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceCB.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceCB.cs index 4d5500c1..22126133 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceCB.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceCB.cs @@ -62,6 +62,7 @@ public partial class TransmissionService { if (download.FileStats?[i].Wanted == null) { + _logger.LogTrace("Skipping file with no stats | {file}", download.Files[i].Name); continue; } @@ -69,12 +70,14 @@ public partial class TransmissionService if (!download.FileStats[i].Wanted.Value) { + _logger.LogTrace("File is already skipped | {file}", download.Files[i].Name); totalUnwantedFiles++; continue; } if (_filenameEvaluator.IsValid(download.Files[i].Name, blocklistType, patterns, regexes)) { + _logger.LogTrace("File is valid | {file}", download.Files[i].Name); continue; } @@ -85,15 +88,17 @@ public partial class TransmissionService if (unwantedFiles.Count is 0) { + _logger.LogDebug("No unwanted files found for {name}", download.Name); return result; } if (totalUnwantedFiles == totalFiles) { + _logger.LogDebug("All files are blocked for {name}", download.Name); result.ShouldRemove = true; } - _logger.LogDebug("marking {count} unwanted files as skipped for {name}", totalUnwantedFiles, download.Name); + _logger.LogDebug("Marking {count} unwanted files as skipped for {name}", totalUnwantedFiles, download.Name); await _dryRunInterceptor.InterceptAsync(SetUnwantedFiles, download.Id, unwantedFiles.ToArray()); diff --git a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceQC.cs b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceQC.cs index 85b5f86b..fbe0ca86 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceQC.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/DownloadClient/Transmission/TransmissionServiceQC.cs @@ -1,6 +1,4 @@ -using System.Collections.Concurrent; -using System.Text.RegularExpressions; -using Cleanuparr.Domain.Entities; +using Cleanuparr.Domain.Entities; using Cleanuparr.Domain.Enums; using Cleanuparr.Infrastructure.Extensions; using Cleanuparr.Infrastructure.Features.Context; @@ -56,6 +54,7 @@ public partial class TransmissionService if (shouldRemove) { // remove if all files are unwanted + _logger.LogDebug("all files are unwanted | removing download | {name}", download.Name); result.ShouldRemove = true; result.DeleteReason = DeleteReason.AllFilesSkipped; return result; @@ -100,11 +99,13 @@ public partial class TransmissionService if (download.Status is not 4) { // not in downloading state + _logger.LogTrace("skip slow check | download is in {state} state | {name}", download.Status, download.Name); return (false, DeleteReason.None); } if (download.RateDownload <= 0) { + _logger.LogTrace("skip slow check | download speed is 0 | {name}", download.Name); return (false, DeleteReason.None); } @@ -142,17 +143,20 @@ public partial class TransmissionService if (queueCleanerConfig.Stalled.MaxStrikes is 0) { + _logger.LogTrace("skip stalled check | max strikes is 0 | {name}", download.Name); return (false, DeleteReason.None); } if (download.Status is not 4) { // not in downloading state + _logger.LogTrace("skip stalled check | download is in {state} state | {name}", download.Status, download.Name); return (false, DeleteReason.None); } if (download.RateDownload > 0 || download.Eta > 0) { + _logger.LogTrace("skip stalled check | download is not stalled | {name}", download.Name); return (false, DeleteReason.None); } diff --git a/code/backend/Cleanuparr.Infrastructure/Features/ItemStriker/Striker.cs b/code/backend/Cleanuparr.Infrastructure/Features/ItemStriker/Striker.cs index e68bfcae..f1118ed1 100644 --- a/code/backend/Cleanuparr.Infrastructure/Features/ItemStriker/Striker.cs +++ b/code/backend/Cleanuparr.Infrastructure/Features/ItemStriker/Striker.cs @@ -27,6 +27,7 @@ public sealed class Striker : IStriker { if (maxStrikes is 0) { + _logger.LogTrace("skip striking for {reason} | max strikes is 0 | {name}", strikeType, itemName); return false; }