< Summary - Combined Code Coverage

Information
Class: NLightning.Application.NLTG.Helpers.ClassNameEnricher
Assembly: NLightning.Application.NLTG
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Application.NLTG/Helpers/ClassNameEnricher.cs
Tag: 30_15166811759
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 22
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Enrich(...)0%2040%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Application.NLTG/Helpers/ClassNameEnricher.cs

#LineLine coverage
 1using Serilog.Core;
 2using Serilog.Events;
 3
 4namespace NLightning.Application.NLTG.Helpers;
 5
 6public class ClassNameEnricher : ILogEventEnricher
 7{
 8    public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 9    {
 010        if (!logEvent.Properties.TryGetValue("SourceContext", out var sourceContextProperty))
 11        {
 012            return;
 13        }
 14
 15        // Extract the class name from the fully qualified type name
 016        var sourceContext = sourceContextProperty.ToString().Trim('"');
 017        var className = sourceContext.Split('.').LastOrDefault() ?? sourceContext;
 18
 019        var classNameProperty = propertyFactory.CreateProperty("ClassName", className);
 020        logEvent.AddPropertyIfAbsent(classNameProperty);
 021    }
 22}