Skip to content

Commit 140c2b6

Browse files
authored
Merge pull request #45 from PandaTechAM/development
Bug fix on application init counter
2 parents c0b2053 + 2a2dbd2 commit 140c2b6

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Shared.Kernel.Demo/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
return response;
7979
});
8080

81-
8281
app.LogStartSuccess();
8382
app.Run();
8483

src/SharedKernel/Logging/StartupLoggerExtensions.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using System.Globalization;
23
using Microsoft.AspNetCore.Builder;
34
using SharedKernel.Extensions;
@@ -6,10 +7,11 @@ namespace SharedKernel.Logging;
67

78
public static class StartupLoggerExtensions
89
{
9-
private static readonly long Stopwatch = System.Diagnostics.Stopwatch.GetTimestamp();
10+
private static long? _startTimestamp = null;
1011

1112
public static WebApplicationBuilder LogStartAttempt(this WebApplicationBuilder builder)
1213
{
14+
_startTimestamp = Stopwatch.GetTimestamp();
1315
var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
1416

1517
Console.ForegroundColor = ConsoleColor.DarkYellow;
@@ -32,7 +34,8 @@ public static WebApplicationBuilder LogStartAttempt(this WebApplicationBuilder b
3234

3335
public static WebApplication LogStartSuccess(this WebApplication app)
3436
{
35-
var delta = System.Diagnostics.Stopwatch.GetElapsedTime(Stopwatch).TotalMilliseconds;
37+
var delta = Stopwatch.GetElapsedTime((long)_startTimestamp!)
38+
.TotalMilliseconds;
3639
var deltaInSeconds = Math.Round(delta / 1000, 2);
3740
var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
3841

@@ -51,8 +54,8 @@ public static WebApplication LogStartSuccess(this WebApplication app)
5154
return app;
5255
}
5356

54-
public static WebApplicationBuilder LogModuleRegistrationSuccess(
55-
this WebApplicationBuilder builder, string moduleName)
57+
public static WebApplicationBuilder LogModuleRegistrationSuccess(this WebApplicationBuilder builder,
58+
string moduleName)
5659
{
5760
var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
5861

src/SharedKernel/SharedKernel.csproj

Lines changed: 2 additions & 2 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.3.2</Version>
11+
<Version>1.3.3</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>Made sync and async optional in logging</PackageReleaseNotes>
17+
<PackageReleaseNotes>Bug fix on application init counter</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

0 commit comments

Comments
 (0)