diff --git a/Directory.Build.props b/Directory.Build.props
index d2a7029..b6d027b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,5 +1,8 @@
9.0.0
+ latest
+ enable
+ enable
diff --git a/src/Seq.Extensions.Logging/Microsoft/Extensions/Logging/SeqLoggerExtensions.cs b/src/Seq.Extensions.Logging/Microsoft/Extensions/Logging/SeqLoggerExtensions.cs
index d94dd2a..afdbca0 100644
--- a/src/Seq.Extensions.Logging/Microsoft/Extensions/Logging/SeqLoggerExtensions.cs
+++ b/src/Seq.Extensions.Logging/Microsoft/Extensions/Logging/SeqLoggerExtensions.cs
@@ -8,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Configuration;
using Serilog.Sinks.PeriodicBatching;
+// ReSharper disable UnusedMember.Global
namespace Microsoft.Extensions.Logging;
@@ -29,7 +30,7 @@ public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, IConfigur
if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory));
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
- if (TryCreateProvider(configuration, LogLevel.Information, Array.Empty>(), out var provider))
+ if (TryCreateProvider(configuration, LogLevel.Information, [], out var provider))
loggerFactory.AddProvider(provider);
return loggerFactory;
@@ -137,16 +138,15 @@ static bool TryCreateProvider(
}
var levelOverrides = new Dictionary();
- foreach (var overr in configuration.GetSection("LevelOverride").GetChildren())
+ foreach (var levelOverride in configuration.GetSection("LevelOverride").GetChildren())
{
- LogLevel value;
- if (!Enum.TryParse(overr.Value, out value))
+ if (!Enum.TryParse(levelOverride.Value, out LogLevel value))
{
- SelfLog.WriteLine("The level override setting `{0}` for `{1}` is invalid", overr.Value, overr.Key);
+ SelfLog.WriteLine("The level override setting `{0}` for `{1}` is invalid", levelOverride.Value, levelOverride.Key);
continue;
}
- levelOverrides[overr.Key] = value;
+ levelOverrides[levelOverride.Key] = value;
}
provider = CreateProvider(serverUrl, apiKey, minimumLevel, levelOverrides, enrichers);
@@ -197,7 +197,7 @@ static SerilogLoggerProvider CreateProvider(
var overrides = new Dictionary();
foreach (var levelOverride in levelOverrides)
{
- overrides.Add(levelOverride.Key, new LoggingLevelSwitch(levelOverride.Value));
+ overrides[levelOverride.Key] = new LoggingLevelSwitch(levelOverride.Value);
}
overrideMap = new LevelOverrideMap(overrides, levelSwitch);
@@ -209,7 +209,7 @@ static SerilogLoggerProvider CreateProvider(
Period = TimeSpan.FromSeconds(2),
});
- var logger = new Logger(batchingSink, new Enricher(enrichers ?? Array.Empty>()), batchingSink.Dispose, levelSwitch, overrideMap);
+ var logger = new Logger(batchingSink, new Enricher(enrichers ?? []), batchingSink.Dispose, levelSwitch, overrideMap);
var provider = new SerilogLoggerProvider(logger);
return provider;
}
diff --git a/src/Seq.Extensions.Logging/Seq.Extensions.Logging.csproj b/src/Seq.Extensions.Logging/Seq.Extensions.Logging.csproj
index baaa76e..bdf66ca 100644
--- a/src/Seq.Extensions.Logging/Seq.Extensions.Logging.csproj
+++ b/src/Seq.Extensions.Logging/Seq.Extensions.Logging.csproj
@@ -13,11 +13,8 @@
icon.png
https://github.com/datalust/seq-extensions-logging
Apache-2.0
- latest
README.md
- enable
- enable
diff --git a/src/Seq.Extensions.Logging/Serilog/Parameters/MessageTemplateProcessor.cs b/src/Seq.Extensions.Logging/Serilog/Parameters/MessageTemplateProcessor.cs
index a9d04b1..f982ebd 100644
--- a/src/Seq.Extensions.Logging/Serilog/Parameters/MessageTemplateProcessor.cs
+++ b/src/Seq.Extensions.Logging/Serilog/Parameters/MessageTemplateProcessor.cs
@@ -12,11 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System.Diagnostics.CodeAnalysis;
using Serilog.Core;
using Serilog.Core.Pipeline;
using Serilog.Events;
-using Serilog.Parsing;
namespace Serilog.Parameters;
diff --git a/test/Seq.Extensions.Logging.Tests/Seq.Extensions.Logging.Tests.csproj b/test/Seq.Extensions.Logging.Tests/Seq.Extensions.Logging.Tests.csproj
index 13bd80f..267380a 100644
--- a/test/Seq.Extensions.Logging.Tests/Seq.Extensions.Logging.Tests.csproj
+++ b/test/Seq.Extensions.Logging.Tests/Seq.Extensions.Logging.Tests.csproj
@@ -6,7 +6,6 @@
true
true
Tests
- latest
diff --git a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnricherTests.cs b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnricherTests.cs
index dbef5ae..18e64fd 100644
--- a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnricherTests.cs
+++ b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnricherTests.cs
@@ -1,7 +1,7 @@
-using System;
using Serilog.Parameters;
using Serilog.Events;
using Seq.Extensions.Logging;
+using Tests.Support;
using Xunit;
namespace Tests.Seq.Extensions.Logging;
@@ -11,54 +11,38 @@ public class EnricherTests
[Fact]
public void EnrichersAreAppliedInOrder()
{
- var evt = new LogEvent(
- default,
- default,
- default,
- default,
- new(),
- default,
- default
- );
+ var evt = Some.EmptyLogEvent();
new Enricher([
- (evt) => evt.AddPropertyIfAbsent("A", 1),
- (evt) => evt.AddPropertyIfAbsent("A", 2),
- (evt) => evt.AddOrUpdateProperty("B", 1),
- (evt) => evt.AddOrUpdateProperty("B", 2),
+ enrichingEvent => enrichingEvent.AddPropertyIfAbsent("A", 1),
+ enrichingEvent => enrichingEvent.AddPropertyIfAbsent("A", 2),
+ enrichingEvent => enrichingEvent.AddOrUpdateProperty("B", 1),
+ enrichingEvent => enrichingEvent.AddOrUpdateProperty("B", 2),
])
.Enrich(
evt,
new PropertyValueConverter(int.MaxValue, int.MaxValue)
);
- Assert.Equal(1, (evt.Properties["A"] as ScalarValue).Value);
- Assert.Equal(2, (evt.Properties["B"] as ScalarValue).Value);
+ Assert.Equal(1, ((ScalarValue)evt.Properties["A"]).Value);
+ Assert.Equal(2, ((ScalarValue)evt.Properties["B"]).Value);
}
[Fact]
public void FailingEnricherIsHandled()
{
- var evt = new LogEvent(
- default,
- default,
- default,
- default,
- new(),
- default,
- default
- );
+ var evt = Some.EmptyLogEvent();
new Enricher([
- (evt) => evt.AddOrUpdateProperty("A", 1),
+ enrichingEvent => enrichingEvent.AddOrUpdateProperty("A", 1),
_ => throw new Exception("Enricher Failed"),
- (evt) => evt.AddOrUpdateProperty("A", 2),
+ enrichingEvent => enrichingEvent.AddOrUpdateProperty("A", 2),
])
.Enrich(
evt,
new PropertyValueConverter(int.MaxValue, int.MaxValue)
);
- Assert.Equal(2, (evt.Properties["A"] as ScalarValue).Value);
+ Assert.Equal(2, ((ScalarValue)evt.Properties["A"]).Value);
}
}
\ No newline at end of file
diff --git a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnrichingEventTests.cs b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnrichingEventTests.cs
index 640ee0f..5e05746 100644
--- a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnrichingEventTests.cs
+++ b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/EnrichingEventTests.cs
@@ -1,8 +1,8 @@
-using System;
using Xunit;
using Serilog.Parameters;
using Serilog.Events;
using Seq.Extensions.Logging;
+using Tests.Support;
namespace Tests.Seq.Extensions.Logging;
@@ -12,43 +12,27 @@ public class EnrichingEventTests
public void AddPropertyIfAbsentAddsProperties()
{
var enriching = new EnrichingEvent(
- new LogEvent(
- default,
- default,
- default,
- default,
- new(),
- default,
- default
- ),
+ Some.EmptyLogEvent(),
new PropertyValueConverter(int.MaxValue, int.MaxValue)
);
enriching.AddPropertyIfAbsent("A", false);
enriching.AddPropertyIfAbsent("A", true);
- Assert.Equal(false, (enriching.LogEvent.Properties["A"] as ScalarValue).Value);
+ Assert.Equal(false, ((ScalarValue)enriching.LogEvent.Properties["A"]).Value);
}
[Fact]
public void AddOrUpdatePropertyAddsProperties()
{
var enriching = new EnrichingEvent(
- new LogEvent(
- default,
- default,
- default,
- default,
- new(),
- default,
- default
- ),
+ Some.EmptyLogEvent(),
new PropertyValueConverter(int.MaxValue, int.MaxValue)
);
enriching.AddOrUpdateProperty("A", false);
enriching.AddOrUpdateProperty("A", true);
- Assert.Equal(true, (enriching.LogEvent.Properties["A"] as ScalarValue).Value);
+ Assert.Equal(true, ((ScalarValue)enriching.LogEvent.Properties["A"]).Value);
}
}
diff --git a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/ExceptionDataEnricherTests.cs b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/ExceptionDataEnricherTests.cs
index 74dcf50..e598ca9 100644
--- a/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/ExceptionDataEnricherTests.cs
+++ b/test/Seq.Extensions.Logging.Tests/Seq/Extensions/Logging/ExceptionDataEnricherTests.cs
@@ -1,7 +1,5 @@
using Seq.Extensions.Logging;
using Serilog.Events;
-using System;
-using System.Linq;
using Tests.Support;
using Xunit;
@@ -25,7 +23,7 @@ public void WhenNoDataIsPresentNoPropertyIsAdded()
public void WhenDataIsPresentThePropertyIsAdded()
{
var enricher = new ExceptionDataEnricher();
- var exception = new Exception()
+ var exception = new Exception
{
Data =
{
diff --git a/test/Seq.Extensions.Logging.Tests/Serilog/Extensions/Logging/SerilogLoggerTests.cs b/test/Seq.Extensions.Logging.Tests/Serilog/Extensions/Logging/SerilogLoggerTests.cs
index de3a925..fe7ac69 100644
--- a/test/Seq.Extensions.Logging.Tests/Serilog/Extensions/Logging/SerilogLoggerTests.cs
+++ b/test/Seq.Extensions.Logging.Tests/Serilog/Extensions/Logging/SerilogLoggerTests.cs
@@ -1,14 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
using System.Collections;
using Serilog.Events;
using Microsoft.Extensions.Logging;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
-using System.Linq;
using Xunit;
using Serilog.Extensions.Logging;
using Seq.Extensions.Logging;
@@ -34,7 +30,7 @@ static SerilogLoggerTests()
{
var sink = new SerilogSink();
- var l = new global::Serilog.Core.Logger(sink, new Enricher(enrichers), null, new global::Serilog.Core.LoggingLevelSwitch(logLevel), null);
+ var l = new global::Serilog.Core.Logger(sink, new Enricher(enrichers), null, new global::Serilog.Core.LoggingLevelSwitch(logLevel));
var provider = new SerilogLoggerProvider(l);
provider.SetScopeProvider(new LoggerExternalScopeProvider());
@@ -138,9 +134,9 @@ public void LogsCorrectMessage()
{
var (logger, sink) = SetUp(LogLevel.Trace);
- logger.Log