Skip to content

Commit

Permalink
remove redundant LogEventLevel (serilog#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored and Twinki14 committed Dec 30, 2023
1 parent bcfa55d commit 23d178a
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 140 deletions.
22 changes: 11 additions & 11 deletions test/Serilog.Tests/Core/LevelOverrideMapTests.cs
Expand Up @@ -4,25 +4,25 @@ public class LevelOverrideMapTests
{
[Theory]
[InlineData("Serilog", false, LevelAlias.Minimum)]
[InlineData("MyApp", true, LogEventLevel.Debug)]
[InlineData("MyApp", true, Debug)]
[InlineData("MyAppSomething", false, LevelAlias.Minimum)]
[InlineData("MyOtherApp", false, LevelAlias.Minimum)]
[InlineData("MyApp.Something", true, LogEventLevel.Debug)]
[InlineData("MyApp.Api.Models.Person", true, LogEventLevel.Error)]
[InlineData("MyApp.Api.Controllers.AboutController", true, LogEventLevel.Information)]
[InlineData("MyApp.Api.Controllers.HomeController", true, LogEventLevel.Warning)]
[InlineData("MyApp.Something", true, Debug)]
[InlineData("MyApp.Api.Models.Person", true, Error)]
[InlineData("MyApp.Api.Controllers.AboutController", true, Information)]
[InlineData("MyApp.Api.Controllers.HomeController", true, Warning)]
[InlineData("Api.Controllers.HomeController", false, LevelAlias.Minimum)]
public void OverrideScenarios(string context, bool overrideExpected, LogEventLevel expected)
{
var overrides = new Dictionary<string, LoggingLevelSwitch>
{
["MyApp"] = new(LogEventLevel.Debug),
["MyApp.Api.Controllers"] = new(LogEventLevel.Information),
["MyApp.Api.Controllers.HomeController"] = new(LogEventLevel.Warning),
["MyApp.Api"] = new(LogEventLevel.Error)
["MyApp"] = new(Debug),
["MyApp.Api.Controllers"] = new(Information),
["MyApp.Api.Controllers.HomeController"] = new(Warning),
["MyApp.Api"] = new(Error)
};

var lom = new LevelOverrideMap(overrides, LogEventLevel.Fatal, null);
var lom = new LevelOverrideMap(overrides, Fatal, null);

lom.GetEffectiveLevel(context, out var overriddenLevel, out var overriddenSwitch);

Expand All @@ -34,7 +34,7 @@ public void OverrideScenarios(string context, bool overrideExpected, LogEventLev
}
else
{
Assert.Equal(LogEventLevel.Fatal, overriddenLevel);
Assert.Equal(Fatal, overriddenLevel);
Assert.Null(overriddenSwitch);
}
}
Expand Down
20 changes: 10 additions & 10 deletions test/Serilog.Tests/Core/LoggerExtensionsTests.cs
Expand Up @@ -3,11 +3,11 @@ namespace Serilog.Tests.Core;
public class LoggerExtensionsTests
{
[Theory]
[InlineData(LogEventLevel.Debug, LogEventLevel.Debug)]
[InlineData(LogEventLevel.Debug, LogEventLevel.Information)]
[InlineData(LogEventLevel.Debug, LogEventLevel.Error)]
[InlineData(LogEventLevel.Debug, LogEventLevel.Fatal)]
[InlineData(LogEventLevel.Debug, LogEventLevel.Warning)]
[InlineData(Debug, Debug)]
[InlineData(Debug, Information)]
[InlineData(Debug, Error)]
[InlineData(Debug, Fatal)]
[InlineData(Debug, Warning)]
public void ShouldEnrichLogEventWhenLevelIsSameOrHigherThanMinLevel(LogEventLevel logMinLevel, LogEventLevel propertyLogLevel)
{
var propValue = Guid.NewGuid();
Expand All @@ -26,11 +26,11 @@ public void ShouldEnrichLogEventWhenLevelIsSameOrHigherThanMinLevel(LogEventLeve
}

[Theory]
[InlineData(LogEventLevel.Debug, LogEventLevel.Verbose)]
[InlineData(LogEventLevel.Information, LogEventLevel.Debug)]
[InlineData(LogEventLevel.Warning, LogEventLevel.Information)]
[InlineData(LogEventLevel.Error, LogEventLevel.Warning)]
[InlineData(LogEventLevel.Fatal, LogEventLevel.Error)]
[InlineData(Debug, Verbose)]
[InlineData(Information, Debug)]
[InlineData(Warning, Information)]
[InlineData(Error, Warning)]
[InlineData(Fatal, Error)]
public void ShouldNotEnrichLogEventsWhenMinLevelIsHigherThanProvidedLogLevel(LogEventLevel logMinLevel, LogEventLevel propertyLogLevel)
{
var propValue = Guid.NewGuid();
Expand Down
8 changes: 4 additions & 4 deletions test/Serilog.Tests/Core/LoggerTests.cs
Expand Up @@ -80,7 +80,7 @@ public void LoggingLevelSwitchDynamicallyChangesLevel(Type loggerType)
log.Warning("Emitted");

// Change the level
levelSwitch.MinimumLevel = LogEventLevel.Error;
levelSwitch.MinimumLevel = Error;

log.Warning("Suppressed");
log.Error("Emitted");
Expand Down Expand Up @@ -179,10 +179,10 @@ public void DelegatingLoggerShouldDelegateCallsToInnerLogger()
log.Debug("suppressed");
Assert.Empty(collectingSink.Events);

log.Write(LogEventLevel.Warning, new Exception("warn"), "emit some {prop} with {values}", "message", new[] { 1, 2, 3 });
log.Write(Warning, new Exception("warn"), "emit some {prop} with {values}", "message", new[] { 1, 2, 3 });

Assert.Single(collectingSink.Events);
Assert.Equal(LogEventLevel.Warning, collectingSink.SingleEvent.Level);
Assert.Equal(Warning, collectingSink.SingleEvent.Level);
Assert.Equal("warn", collectingSink.SingleEvent.Exception?.Message);
Assert.Equal("string", collectingSink.SingleEvent.Properties["type"].LiteralValue());
Assert.Equal("message", collectingSink.SingleEvent.Properties["prop"].LiteralValue());
Expand All @@ -192,7 +192,7 @@ public void DelegatingLoggerShouldDelegateCallsToInnerLogger()
actual: (SequenceValue)collectingSink.SingleEvent.Properties["values"],
comparer: new LogEventPropertyValueComparer());

levelSwitch.MinimumLevel = LogEventLevel.Fatal;
levelSwitch.MinimumLevel = Fatal;
collectingSink.Events.Clear();

log.Error("error");
Expand Down
2 changes: 1 addition & 1 deletion test/Serilog.Tests/Core/SecondaryLoggerSinkTests.cs
Expand Up @@ -74,7 +74,7 @@ public void ChildLoggerCanOverrideInheritedLevel()
var sink = new CollectingSink();

var logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(new LoggingLevelSwitch(LogEventLevel.Debug))
.MinimumLevel.ControlledBy(new(Debug))
.WriteTo.Logger(lc => lc
.MinimumLevel.Error()
.WriteTo.Sink(sink))
Expand Down
2 changes: 1 addition & 1 deletion test/Serilog.Tests/Events/LogEventPropertyValueTests.cs
Expand Up @@ -22,7 +22,7 @@ public class LogEventPropertyValueTests
[Fact]
public void AnEnumIsConvertedToANonStringScalarValue()
{
var value = _converter.CreatePropertyValue(LogEventLevel.Debug, Destructuring.Default);
var value = _converter.CreatePropertyValue(Debug, Destructuring.Default);
Assert.IsType<ScalarValue>(value);
var sv = (ScalarValue)value;
Assert.NotNull(sv.Value);
Expand Down
Expand Up @@ -45,52 +45,52 @@ public void LowercaseFormatSpecifierIsSupportedForStrings()
}

[Theory]
[InlineData(LogEventLevel.Verbose, 1, "V")]
[InlineData(LogEventLevel.Verbose, 2, "Vb")]
[InlineData(LogEventLevel.Verbose, 3, "Vrb")]
[InlineData(LogEventLevel.Verbose, 4, "Verb")]
[InlineData(LogEventLevel.Verbose, 5, "Verbo")]
[InlineData(LogEventLevel.Verbose, 6, "Verbos")]
[InlineData(LogEventLevel.Verbose, 7, "Verbose")]
[InlineData(LogEventLevel.Verbose, 8, "Verbose")]
[InlineData(LogEventLevel.Debug, 1, "D")]
[InlineData(LogEventLevel.Debug, 2, "De")]
[InlineData(LogEventLevel.Debug, 3, "Dbg")]
[InlineData(LogEventLevel.Debug, 4, "Dbug")]
[InlineData(LogEventLevel.Debug, 5, "Debug")]
[InlineData(LogEventLevel.Debug, 6, "Debug")]
[InlineData(LogEventLevel.Information, 1, "I")]
[InlineData(LogEventLevel.Information, 2, "In")]
[InlineData(LogEventLevel.Information, 3, "Inf")]
[InlineData(LogEventLevel.Information, 4, "Info")]
[InlineData(LogEventLevel.Information, 5, "Infor")]
[InlineData(LogEventLevel.Information, 6, "Inform")]
[InlineData(LogEventLevel.Information, 7, "Informa")]
[InlineData(LogEventLevel.Information, 8, "Informat")]
[InlineData(LogEventLevel.Information, 9, "Informati")]
[InlineData(LogEventLevel.Information, 10, "Informatio")]
[InlineData(LogEventLevel.Information, 11, "Information")]
[InlineData(LogEventLevel.Information, 12, "Information")]
[InlineData(LogEventLevel.Error, 1, "E")]
[InlineData(LogEventLevel.Error, 2, "Er")]
[InlineData(LogEventLevel.Error, 3, "Err")]
[InlineData(LogEventLevel.Error, 4, "Eror")]
[InlineData(LogEventLevel.Error, 5, "Error")]
[InlineData(LogEventLevel.Error, 6, "Error")]
[InlineData(LogEventLevel.Fatal, 1, "F")]
[InlineData(LogEventLevel.Fatal, 2, "Fa")]
[InlineData(LogEventLevel.Fatal, 3, "Ftl")]
[InlineData(LogEventLevel.Fatal, 4, "Fatl")]
[InlineData(LogEventLevel.Fatal, 5, "Fatal")]
[InlineData(LogEventLevel.Fatal, 6, "Fatal")]
[InlineData(LogEventLevel.Warning, 1, "W")]
[InlineData(LogEventLevel.Warning, 2, "Wn")]
[InlineData(LogEventLevel.Warning, 3, "Wrn")]
[InlineData(LogEventLevel.Warning, 4, "Warn")]
[InlineData(LogEventLevel.Warning, 5, "Warni")]
[InlineData(LogEventLevel.Warning, 6, "Warnin")]
[InlineData(LogEventLevel.Warning, 7, "Warning")]
[InlineData(LogEventLevel.Warning, 8, "Warning")]
[InlineData(Verbose, 1, "V")]
[InlineData(Verbose, 2, "Vb")]
[InlineData(Verbose, 3, "Vrb")]
[InlineData(Verbose, 4, "Verb")]
[InlineData(Verbose, 5, "Verbo")]
[InlineData(Verbose, 6, "Verbos")]
[InlineData(Verbose, 7, "Verbose")]
[InlineData(Verbose, 8, "Verbose")]
[InlineData(Debug, 1, "D")]
[InlineData(Debug, 2, "De")]
[InlineData(Debug, 3, "Dbg")]
[InlineData(Debug, 4, "Dbug")]
[InlineData(Debug, 5, "Debug")]
[InlineData(Debug, 6, "Debug")]
[InlineData(Information, 1, "I")]
[InlineData(Information, 2, "In")]
[InlineData(Information, 3, "Inf")]
[InlineData(Information, 4, "Info")]
[InlineData(Information, 5, "Infor")]
[InlineData(Information, 6, "Inform")]
[InlineData(Information, 7, "Informa")]
[InlineData(Information, 8, "Informat")]
[InlineData(Information, 9, "Informati")]
[InlineData(Information, 10, "Informatio")]
[InlineData(Information, 11, "Information")]
[InlineData(Information, 12, "Information")]
[InlineData(Error, 1, "E")]
[InlineData(Error, 2, "Er")]
[InlineData(Error, 3, "Err")]
[InlineData(Error, 4, "Eror")]
[InlineData(Error, 5, "Error")]
[InlineData(Error, 6, "Error")]
[InlineData(Fatal, 1, "F")]
[InlineData(Fatal, 2, "Fa")]
[InlineData(Fatal, 3, "Ftl")]
[InlineData(Fatal, 4, "Fatl")]
[InlineData(Fatal, 5, "Fatal")]
[InlineData(Fatal, 6, "Fatal")]
[InlineData(Warning, 1, "W")]
[InlineData(Warning, 2, "Wn")]
[InlineData(Warning, 3, "Wrn")]
[InlineData(Warning, 4, "Warn")]
[InlineData(Warning, 5, "Warni")]
[InlineData(Warning, 6, "Warnin")]
[InlineData(Warning, 7, "Warning")]
[InlineData(Warning, 8, "Warning")]
public void FixedLengthLevelIsSupported(
LogEventLevel level,
int width,
Expand Down
12 changes: 6 additions & 6 deletions test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs
Expand Up @@ -9,7 +9,7 @@ public void JsonFormattedEventsIncludeTimestamp()
{
var @event = new LogEvent(
new DateTimeOffset(2013, 3, 11, 15, 59, 0, 123, TimeSpan.FromHours(10)),
LogEventLevel.Information,
Information,
null,
Some.MessageTemplate(),
new LogEventProperty[0]);
Expand All @@ -28,7 +28,7 @@ public void JsonFormattedDateOnly()
{
var @event = new LogEvent(
DateTimeOffset.MaxValue,
LogEventLevel.Information,
Information,
null,
Some.MessageTemplate(),
new[] {new LogEventProperty("name", new ScalarValue(DateOnly.MaxValue))});
Expand All @@ -44,7 +44,7 @@ public void JsonFormattedTimeOnly()
{
var @event = new LogEvent(
DateTimeOffset.MaxValue,
LogEventLevel.Information,
Information,
null,
Some.MessageTemplate(),
new[] {new LogEventProperty("name", new ScalarValue(TimeOnly.MaxValue))});
Expand Down Expand Up @@ -202,7 +202,7 @@ public void DictionariesAreDestructuredViaDictionaryValue()
public void PropertyTokensWithFormatStringsAreIncludedAsRenderings()
{
var p = new MessageTemplateParser();
var e = new LogEvent(Some.OffsetInstant(), LogEventLevel.Information, null,
var e = new LogEvent(Some.OffsetInstant(), Information, null,
p.Parse("{AProperty:000}"), new[] { new LogEventProperty("AProperty", new ScalarValue(12)) });

var d = FormatEvent(e);
Expand Down Expand Up @@ -230,7 +230,7 @@ static dynamic FormatEvent(LogEvent e)
public void PropertyTokensWithoutFormatStringsAreNotIncludedAsRenderings()
{
var p = new MessageTemplateParser();
var e = new LogEvent(Some.OffsetInstant(), LogEventLevel.Information, null,
var e = new LogEvent(Some.OffsetInstant(), Information, null,
p.Parse("{AProperty}"), new[] { new LogEventProperty("AProperty", new ScalarValue(12)) });

var d = FormatEvent(e);
Expand All @@ -243,7 +243,7 @@ public void PropertyTokensWithoutFormatStringsAreNotIncludedAsRenderings()
public void SequencesOfSequencesAreSerialized()
{
var p = new MessageTemplateParser();
var e = new LogEvent(Some.OffsetInstant(), LogEventLevel.Information, null,
var e = new LogEvent(Some.OffsetInstant(), Information, null,
p.Parse("{@AProperty}"), new[] { new LogEventProperty("AProperty", new SequenceValue(new[] { new SequenceValue(new[] { new ScalarValue("Hello") }) })) });

var d = FormatEvent(e);
Expand Down

0 comments on commit 23d178a

Please sign in to comment.