Skip to content

Commit c862bfc

Browse files
authored
Merge pull request #367 from sungam3r/cleanup
Remove excessive dependencies + format
2 parents 0b2a9ab + 656b79e commit c862bfc

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
lines changed

samples/Sample/Controllers/HomeController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public IActionResult Privacy()
3535
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
3636
public IActionResult Error()
3737
{
38-
return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier});
38+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
3939
}
4040
}

samples/Sample/Sample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<ProjectReference Include="..\..\src\Serilog.AspNetCore\Serilog.AspNetCore.csproj" />
99
</ItemGroup>
10-
10+
1111
<ItemGroup>
1212
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
1313
</ItemGroup>

src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RequestLoggingMiddleware
3232
readonly Func<HttpContext, string, double, int, IEnumerable<LogEventProperty>> _getMessageTemplateProperties;
3333
readonly ILogger? _logger;
3434
readonly bool _includeQueryInRequestPath;
35-
static readonly LogEventProperty[] NoProperties = Array.Empty<LogEventProperty>();
35+
static readonly LogEventProperty[] NoProperties = [];
3636

3737
public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnosticContext, RequestLoggingOptions options)
3838
{
@@ -102,7 +102,7 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector
102102
properties,
103103
traceId,
104104
spanId);
105-
105+
106106
logger.Write(evt);
107107

108108
return false;

src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception? ex) =
3535
: LogEventLevel.Information;
3636

3737
static IEnumerable<LogEventProperty> DefaultGetMessageTemplateProperties(HttpContext httpContext, string requestPath, double elapsedMs, int statusCode) =>
38-
new[]
39-
{
38+
[
4039
new LogEventProperty("RequestMethod", new ScalarValue(httpContext.Request.Method)),
4140
new LogEventProperty("RequestPath", new ScalarValue(requestPath)),
4241
new LogEventProperty("StatusCode", new ScalarValue(statusCode)),
4342
new LogEventProperty("Elapsed", new ScalarValue(elapsedMs))
44-
};
43+
];
4544

4645
/// <summary>
4746
/// Gets or sets the message template. The default value is

src/Serilog.AspNetCore/Serilog.AspNetCore.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535
<!-- The versions of all references in this group must match the major and minor components of the package version prefix. -->
3636
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
3737
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
38-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
3938
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
40-
<!-- Temporary addition to pull in trace/span support -->
41-
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
4239
</ItemGroup>
4340

4441
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' and '$(TargetFramework)' != 'netstandard2.0' ">

test/Serilog.AspNetCore.Tests/SerilogWebHostBuilderExtensionsTests.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ public async Task RequestLoggingMiddlewareShouldEnrichWithCustomisedProperties()
7171
{
7272
options.MessageTemplate = "HTTP {RequestMethod} responded {Status} in {ElapsedMilliseconds:0.0000} ms";
7373
options.GetMessageTemplateProperties = (ctx, _, elapsedMs, status) =>
74-
new[]
75-
{
74+
[
7675
new LogEventProperty("RequestMethod", new ScalarValue(ctx.Request.Method)),
7776
new LogEventProperty("Status", new ScalarValue(status)),
7877
new LogEventProperty("ElapsedMilliseconds", new ScalarValue(elapsedMs))
79-
};
78+
];
8079
});
8180

8281
await web.CreateClient().GetAsync("/resource");
@@ -164,7 +163,7 @@ WebApplicationFactory<TestStartup> Setup(
164163

165164
return web;
166165
}
167-
166+
168167
[Fact]
169168
public async Task RequestLoggingMiddlewareShouldAddTraceAndSpanIds()
170169
{

test/Serilog.AspNetCore.Tests/Support/SerilogSink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Serilog.AspNetCore.Tests.Support;
88

99
public class SerilogSink : ILogEventSink
1010
{
11-
public List<LogEvent> Writes { get; set; } = new();
11+
public List<LogEvent> Writes { get; set; } = [];
1212

1313
public void Emit(LogEvent logEvent)
1414
{

0 commit comments

Comments
 (0)