Skip to content

Commit

Permalink
Log executing health check
Browse files Browse the repository at this point in the history
�Towards #6076
  • Loading branch information
markus101 committed Oct 10, 2023
1 parent 4b9badd commit 78b39bd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/NzbDrone.Core/HealthCheck/HealthCheckService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging;
Expand Down Expand Up @@ -28,6 +29,7 @@ public class HealthCheckService : IHealthCheckService,
private readonly IProvideHealthCheck[] _scheduledHealthChecks;
private readonly Dictionary<Type, IEventDrivenHealthCheck[]> _eventDrivenHealthChecks;
private readonly IEventAggregator _eventAggregator;
private readonly Logger _logger;

private readonly ICached<HealthCheck> _healthCheckResults;
private readonly HashSet<IProvideHealthCheck> _pendingHealthChecks;
Expand All @@ -40,10 +42,12 @@ public class HealthCheckService : IHealthCheckService,
IEventAggregator eventAggregator,
ICacheManager cacheManager,
IDebounceManager debounceManager,
IRuntimeInfo runtimeInfo)
IRuntimeInfo runtimeInfo,
Logger logger)
{
_healthChecks = healthChecks.ToArray();
_eventAggregator = eventAggregator;
_logger = logger;

_healthCheckResults = cacheManager.GetCache<HealthCheck>(GetType());
_pendingHealthChecks = new HashSet<IProvideHealthCheck>();
Expand Down Expand Up @@ -88,7 +92,14 @@ private void ProcessHealthChecks()

try
{
var results = healthChecks.Select(c => c.Check())
var results = healthChecks.Select(c =>
{
_logger.Trace("Check health -> {0}", c.GetType().Name);
var result = c.Check();
_logger.Trace("Check health <- {0}", c.GetType().Name);
return result;
})
.ToList();

foreach (var result in results)
Expand Down

0 comments on commit 78b39bd

Please sign in to comment.