< Summary

Information
Class: Orchestrator.LoggingConfiguration<T>
Assembly: Orchestrator
File(s): /home/runner/work/KicktippAi/KicktippAi/src/Orchestrator/LoggingConfiguration.cs
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 41
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
.cctor()100%11100%
GetMinimumLevelForCommandLine(...)100%22100%
CreateLogger<T>(...)100%11100%

File(s)

/home/runner/work/KicktippAi/KicktippAi/src/Orchestrator/LoggingConfiguration.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2using Microsoft.Extensions.Logging;
 3
 4namespace Orchestrator;
 5
 6public static class LoggingConfiguration
 7{
 18    private static readonly HashSet<string> QuietExperimentRunCommands = new(StringComparer.OrdinalIgnoreCase)
 19    {
 110        "run-slice",
 111        "run-repeated-match",
 112        "run-repeated-match-slice",
 113        "run-community-to-date"
 114    };
 15
 16    public static LogLevel GetMinimumLevelForCommandLine(IEnumerable<string> args)
 17    {
 118        ArgumentNullException.ThrowIfNull(args);
 19
 120        return args.Any(QuietExperimentRunCommands.Contains)
 121            ? LogLevel.Warning
 122            : LogLevel.Information;
 23    }
 24
 25    public static ILogger<T> CreateLogger<T>(LogLevel minimumLevel = LogLevel.Information)
 26    {
 127        var serviceCollection = new ServiceCollection();
 128        serviceCollection.AddLogging(builder =>
 129            builder.AddSimpleConsole(options =>
 130            {
 131                options.SingleLine = true;
 132                options.IncludeScopes = false;
 133                options.TimestampFormat = null;
 134                options.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Enabled;
 135            })
 136            .SetMinimumLevel(minimumLevel));
 37
 138        var serviceProvider = serviceCollection.BuildServiceProvider();
 139        return serviceProvider.GetRequiredService<ILogger<T>>();
 40    }
 41}