< Summary

Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 1359
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .cctor()100%11100%
File 2: .ctor(...)100%11100%
File 2: Succeeded()100%22100%
File 2: Failed(...)100%22100%

File(s)

/home/runner/work/anichron/anichron/src/.artifacts/obj/Anichron.Worker/debug/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs

File '/home/runner/work/anichron/anichron/src/.artifacts/obj/Anichron.Worker/debug/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs' does not exist (any more).

/home/runner/work/anichron/anichron/src/Anichron.Worker/Scheduling/OutageLog.cs

#LineLine coverage
 1namespace Anichron.Worker.Scheduling;
 2
 3/// <summary>
 4/// Logs a poll loop's outage once: the first failure as an error with its exception, each following one at debug,
 5/// and the first success after it as a recovery.
 6/// </summary>
 7/// <param name="logger">The poll loop's own logger.</param>
 8/// <param name="operation">What the loop does, as the start of a sentence.</param>
 429internal sealed partial class OutageLog(ILogger logger, string operation)
 10{
 11    private bool failing;
 12
 13    public void Succeeded()
 6814    {
 6815        if (!failing)
 6316            return;
 17
 518        failing = false;
 519        Log.Recovered(logger, operation);
 6820    }
 21
 22    public void Failed(Exception ex)
 1123    {
 1124        if (failing)
 425            Log.StillFailing(logger, operation);
 26        else
 727            Log.Failed(logger, operation, ex);
 1128        failing = true;
 1129    }
 30
 31    private static partial class Log
 32    {
 33        [LoggerMessage(Level = LogLevel.Error, Message = "{Operation} failed; will retry at the next poll.")]
 34        public static partial void Failed(ILogger logger, string operation, Exception ex);
 35
 36        [LoggerMessage(Level = LogLevel.Debug, Message = "{Operation} failed again; will retry at the next poll.")]
 37        public static partial void StillFailing(ILogger logger, string operation);
 38
 39        [LoggerMessage(Level = LogLevel.Information, Message = "{Operation} works again.")]
 40        public static partial void Recovered(ILogger logger, string operation);
 41    }
 42}