Avoid varying logging message template between calls

This commit is contained in:
Bogdan 2025-04-29 11:35:57 +03:00
parent c58a9b3f2c
commit c2c3dfe917
2 changed files with 8 additions and 15 deletions

View file

@ -12,8 +12,6 @@ namespace NzbDrone.Core.Indexers
{
public class RssSyncService : IExecute<RssSyncCommand>
{
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<RssSyncCommand>
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<ProcessedDecisions> 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<ProcessedDecisions> Sync()
public void Execute(RssSyncCommand message)
{
var processed = Sync().GetAwaiter().GetResult();
var grabbedOrPending = processed.Grabbed.Concat(processed.Pending).ToList();
_eventAggregator.PublishEvent(new RssSyncCompleteEvent(processed));
}

View file

@ -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<string, object> { { "exceptionMessage", ex.Message } }));
}
@ -103,7 +103,7 @@ public ValidationFailure Test(AppriseSettings settings)
{
var error = Json.Deserialize<AppriseError>(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<string, object> { { "error", error.Error } }));
}