Skip to content

Commit ff8d4b6

Browse files
authored
Merge pull request #39 from PandaTechAM/development
Logging middleware efficiency boosted
2 parents 9e96ed8 + a1b6a8b commit ff8d4b6

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Shared.Kernel.Demo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
.AddControllers(AssemblyRegistry.ToArray())
2828
.AddMediatrWithBehaviors(AssemblyRegistry.ToArray())
2929
.AddResilienceDefaultPipeline()
30-
.AddDistributedSignalR("redis://localhost:6379", "app_name:") // or .AddSignalR()
30+
.AddDistributedSignalR("localhost:6379", "app_name:") // or .AddSignalR()
3131
.AddDistributedCache(o =>
3232
{
33-
o.RedisConnectionString = "redis://localhost:6379";
33+
o.RedisConnectionString = "localhost:6379";
3434
o.ChannelPrefix = "app_name:";
3535
})
3636
.MapDefaultTimeZone()

Shared.Kernel.Demo/appsettings.Development.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"MinimumLevel": {
44
"Default": "Information",
55
"Override": {
6-
"Microsoft": "Information",
7-
"System": "Information"
6+
"Microsoft": "Warning",
7+
"System": "Warning"
88
}
99
}
1010
},

src/SharedKernel/Logging/RequestLoggingMiddleware.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ internal sealed class RequestLoggingMiddleware(
99
RequestDelegate next,
1010
ILogger<RequestLoggingMiddleware> logger)
1111
{
12+
private static readonly HashSet<string> PathsToIgnore =
13+
[
14+
"/openapi",
15+
"/above-board"
16+
];
17+
1218
public async Task InvokeAsync(HttpContext context)
1319
{
1420
if (HttpMethods.IsOptions(context.Request.Method))
@@ -17,6 +23,13 @@ public async Task InvokeAsync(HttpContext context)
1723
return;
1824
}
1925

26+
if (context.Request.Path.HasValue &&
27+
PathsToIgnore.Any(p => context.Request.Path.StartsWithSegments(p)))
28+
{
29+
await next(context);
30+
return;
31+
}
32+
2033
var requestLog = await CaptureRequestAsync(context.Request);
2134
var originalBodyStream = context.Response.Body;
2235

src/SharedKernel/SharedKernel.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>1.2.9</Version>
11+
<Version>1.2.10</Version>
1212
<PackageId>Pandatech.SharedKernel</PackageId>
1313
<Title>Pandatech Shared Kernel Library</Title>
1414
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
1515
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
17-
<PackageReleaseNotes>Nuget updates</PackageReleaseNotes>
17+
<PackageReleaseNotes>Logging middleware efficiency boosted</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>
@@ -48,14 +48,14 @@
4848
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.11.0" />
4949
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.11.0" />
5050
<PackageReference Include="Pandatech.Crypto" Version="4.1.2" />
51-
<PackageReference Include="Pandatech.DistributedCache" Version="4.0.6" />
51+
<PackageReference Include="Pandatech.DistributedCache" Version="4.0.7" />
5252
<PackageReference Include="Pandatech.FluentMinimalApiMapper" Version="2.0.2" />
5353
<PackageReference Include="Pandatech.PandaVaultClient" Version="4.0.4" />
5454
<PackageReference Include="Pandatech.RegexBox" Version="3.0.1" />
5555
<PackageReference Include="Pandatech.ResponseCrafter" Version="5.1.8" />
56-
<PackageReference Include="Scalar.AspNetCore" Version="2.0.14" />
56+
<PackageReference Include="Scalar.AspNetCore" Version="2.0.18" />
5757
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
58-
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
58+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.3.1" />
5959
</ItemGroup>
6060

6161
</Project>

0 commit comments

Comments
 (0)