From c2c3dfe917bbcc50c2012f977e52b39a3554522c Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 29 Apr 2025 11:35:57 +0300 Subject: [PATCH] Avoid varying logging message template between calls --- src/NzbDrone.Core/Indexers/RssSyncService.cs | 19 ++++++------------- .../Notifications/Apprise/AppriseProxy.cs | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/RssSyncService.cs b/src/NzbDrone.Core/Indexers/RssSyncService.cs index 46e0c07072..2380b00f1d 100644 --- a/src/NzbDrone.Core/Indexers/RssSyncService.cs +++ b/src/NzbDrone.Core/Indexers/RssSyncService.cs @@ -12,8 +12,6 @@ namespace NzbDrone.Core.Indexers { public class RssSyncService : IExecute { - private readonly IIndexerStatusService _indexerStatusService; - private readonly IIndexerFactory _indexerFactory; private readonly IFetchAndParseRss _rssFetcherAndParser; private readonly IMakeDownloadDecision _downloadDecisionMaker; private readonly IProcessDownloadDecisions _processDownloadDecisions; @@ -21,17 +19,13 @@ public class RssSyncService : IExecute private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; - public RssSyncService(IIndexerStatusService indexerStatusService, - IIndexerFactory indexerFactory, - IFetchAndParseRss rssFetcherAndParser, + public RssSyncService(IFetchAndParseRss rssFetcherAndParser, IMakeDownloadDecision downloadDecisionMaker, IProcessDownloadDecisions processDownloadDecisions, IPendingReleaseService pendingReleaseService, IEventAggregator eventAggregator, Logger logger) { - _indexerStatusService = indexerStatusService; - _indexerFactory = indexerFactory; _rssFetcherAndParser = rssFetcherAndParser; _downloadDecisionMaker = downloadDecisionMaker; _processDownloadDecisions = processDownloadDecisions; @@ -51,14 +45,14 @@ private async Task Sync() var decisions = _downloadDecisionMaker.GetRssDecision(reports); var processed = await _processDownloadDecisions.ProcessDecisions(decisions); - var message = string.Format("RSS Sync Completed. Reports found: {0}, Reports grabbed: {1}", reports.Count, processed.Grabbed.Count); - if (processed.Pending.Any()) { - message += ", Reports pending: " + processed.Pending.Count; + _logger.ProgressInfo("RSS Sync Completed. Reports found: {0}, Reports grabbed: {1}, Reports pending: {2}", reports.Count, processed.Grabbed.Count, processed.Pending.Count); + } + else + { + _logger.ProgressInfo("RSS Sync Completed. Reports found: {0}, Reports grabbed: {1}", reports.Count, processed.Grabbed.Count); } - - _logger.ProgressInfo(message); return processed; } @@ -66,7 +60,6 @@ private async Task Sync() public void Execute(RssSyncCommand message) { var processed = Sync().GetAwaiter().GetResult(); - var grabbedOrPending = processed.Grabbed.Concat(processed.Pending).ToList(); _eventAggregator.PublishEvent(new RssSyncCompleteEvent(processed)); } diff --git a/src/NzbDrone.Core/Notifications/Apprise/AppriseProxy.cs b/src/NzbDrone.Core/Notifications/Apprise/AppriseProxy.cs index 86a5e395b1..b30b60058a 100644 --- a/src/NzbDrone.Core/Notifications/Apprise/AppriseProxy.cs +++ b/src/NzbDrone.Core/Notifications/Apprise/AppriseProxy.cs @@ -95,7 +95,7 @@ public ValidationFailure Test(AppriseSettings settings) { if (httpException.Response.StatusCode == HttpStatusCode.Unauthorized) { - _logger.Error(ex, $"HTTP Auth credentials are invalid: {0}", ex.Message); + _logger.Error(ex, "HTTP Auth credentials are invalid: {0}", ex.Message); return new ValidationFailure("AuthUsername", _localizationService.GetLocalizedString("NotificationsValidationInvalidHttpCredentials", new Dictionary { { "exceptionMessage", ex.Message } })); } @@ -103,7 +103,7 @@ public ValidationFailure Test(AppriseSettings settings) { var error = Json.Deserialize(httpException.Response.Content); - _logger.Error(ex, $"Unable to send test message. Response from API: {0}", error.Error); + _logger.Error(ex, "Unable to send test message. Response from API: {0}", error.Error); return new ValidationFailure(string.Empty, _localizationService.GetLocalizedString("NotificationsValidationUnableToSendTestMessageApiResponse", new Dictionary { { "error", error.Error } })); }