Skip to content

Commit adf275f

Browse files
committed
Tighter level mapping, though for invalid cases only
1 parent 7bdddec commit adf275f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Serilog.Extensions.Logging/Extensions/Logging/LevelConvert.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public static LogEventLevel ToSerilogLevel(LogLevel logLevel)
3636
{
3737
return logLevel switch
3838
{
39-
LogLevel.None or LogLevel.Critical => LogEventLevel.Fatal,
39+
LogLevel.None => LevelAlias.Off,
40+
LogLevel.Critical => LogEventLevel.Fatal,
4041
LogLevel.Error => LogEventLevel.Error,
4142
LogLevel.Warning => LogEventLevel.Warning,
4243
LogLevel.Information => LogEventLevel.Information,

test/Serilog.Extensions.Logging.Benchmarks/LogEventConstructionBenchmark.cs renamed to test/Serilog.Extensions.Logging.Benchmarks/EventIdCapturingBenchmark.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
namespace Serilog.Extensions.Logging.Benchmarks;
2424

2525
[MemoryDiagnoser]
26-
public class LogEventConstructionBenchmark
26+
public class EventIdCapturingBenchmark
2727
{
2828
readonly IMelLogger _melLogger;
2929
readonly ILogger _serilogContextualLogger;
3030
readonly CapturingSink _sink;
3131
const int LowId = 10, HighId = 101;
3232
const string Template = "This is an event";
3333

34-
public LogEventConstructionBenchmark()
34+
public EventIdCapturingBenchmark()
3535
{
3636
_sink = new CapturingSink();
3737
var underlyingLogger = new LoggerConfiguration().WriteTo.Sink(_sink).CreateLogger();
38-
_serilogContextualLogger = underlyingLogger.ForContext<LogEventConstructionBenchmark>();
38+
_serilogContextualLogger = underlyingLogger.ForContext<EventIdCapturingBenchmark>();
3939
_melLogger = new SerilogLoggerProvider(underlyingLogger).CreateLogger(GetType().FullName!);
4040
}
4141

@@ -68,7 +68,7 @@ public void Verify()
6868
[Fact]
6969
public void Benchmark()
7070
{
71-
BenchmarkRunner.Run<LogEventConstructionBenchmark>();
71+
BenchmarkRunner.Run<EventIdCapturingBenchmark>();
7272
}
7373

7474
[Benchmark(Baseline = true)]

0 commit comments

Comments
 (0)