Skip to content

Commit 3f09d4c

Browse files
author
Timothy Dodd
committed
Update dependencies and enhance log parsing functionality
Updated Microsoft libraries in project files to version 9.0.8, including `Microsoft.Extensions.Http`, `Microsoft.Extensions.Hosting`, `System.Text.Json`, and `Microsoft.AspNetCore.Authentication.JwtBearer`. Enhanced log level detection in `LogParser.cs` by adding patterns for "FAIL:", "WARN:", "INFO:", and "DEBUG:". Added safety checks in `ParseContainerLogFormat` to ensure substring extraction is within bounds. Minor whitespace adjustment in `LogParser.cs` for improved code readability.
1 parent 20daee9 commit 3f09d4c

5 files changed

Lines changed: 1937 additions & 1592 deletions

File tree

src/LogMkAgent/LogMkAgent.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.7" />
17-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.7" />
18-
<PackageReference Include="System.Text.Json" Version="9.0.7" />
16+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.8" />
17+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
18+
<PackageReference Include="System.Text.Json" Version="9.0.8" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

src/LogMkApi/LogMkApi.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
<ItemGroup>
1616

17-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.7" />
18-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.7" />
17+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.8" />
18+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
1919
<PackageReference Include="MySql.Data" Version="9.4.0" />
2020
<PackageReference Include="ServiceStack.OrmLite.MySql" Version="8.8.0" />
21-
<PackageReference Include="System.Text.Json" Version="9.0.7" />
21+
<PackageReference Include="System.Text.Json" Version="9.0.8" />
2222
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
23-
<Version>9.0.7</Version>
23+
<Version>9.0.8</Version>
2424
</PackageReference>
2525
</ItemGroup>
2626
<ItemGroup>

src/LogMkCommon/LogParser.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Text.RegularExpressions;
33

44
namespace LogMkCommon;
@@ -55,10 +55,10 @@ public static LogLevel ParseLogLevel(string line)
5555

5656
// Remove ANSI escape sequences first
5757
var cleanLine = RemoveANSIEscapeRegex.Replace(line, string.Empty);
58-
58+
5959
// Parse container format to get actual log content
6060
var processedLine = ParseContainerLogFormat(line, cleanLine);
61-
61+
6262
return GetLogLevel(processedLine);
6363
}
6464

@@ -70,13 +70,13 @@ private static LogLevel GetLogLevel(string logLine)
7070
var upperLine = logLine.ToUpperInvariant();
7171

7272
// Check for common log level patterns with boundaries
73-
if (ContainsLogLevel(upperLine, "[ERROR]", "ERROR:", " ERR ", "ERROR "))
73+
if (ContainsLogLevel(upperLine, "[ERROR]", "ERROR:", " ERR ", "ERROR ", "FAIL:"))
7474
return LogLevel.Error;
75-
if (ContainsLogLevel(upperLine, "[WARN]", "[WARNING]", "WARNING:", " WARN ", " WRN "))
75+
if (ContainsLogLevel(upperLine, "[WARN]", "[WARNING]", "WARNING:", " WARN ", " WRN ", "WARN:"))
7676
return LogLevel.Warning;
77-
if (ContainsLogLevel(upperLine, "[INFO]", "[INFORMATION]", "INFORMATION:", " INFO ", " INF "))
77+
if (ContainsLogLevel(upperLine, "[INFO]", "[INFORMATION]", "INFORMATION:", " INFO ", " INF ", "INFO:"))
7878
return LogLevel.Information;
79-
if (ContainsLogLevel(upperLine, "[DEBUG]", "DEBUG:", " DBG ", " DEBUG "))
79+
if (ContainsLogLevel(upperLine, "[DEBUG]", "DEBUG:", " DBG ", "DBUG:", " DEBUG "))
8080
return LogLevel.Debug;
8181
if (ContainsLogLevel(upperLine, "[TRACE]", "TRACE:", " TRC ", " TRACE "))
8282
return LogLevel.Trace;
@@ -122,7 +122,7 @@ public static string ParseContainerLogFormat(string originalLine, string cleanLi
122122
// Calculate the position adjustment due to ANSI escape sequences removal
123123
var lengthDiff = originalLine.Length - cleanLine.Length;
124124
var adjustedPosition = thirdSpace + 1 - lengthDiff;
125-
125+
126126
if (adjustedPosition >= 0 && adjustedPosition < cleanLine.Length)
127127
{
128128
return cleanLine.Substring(adjustedPosition);
@@ -170,4 +170,4 @@ public static string RemoveANSIEscapeSequences(string line)
170170
{
171171
return RemoveANSIEscapeRegex.Replace(line, string.Empty);
172172
}
173-
}
173+
}

0 commit comments

Comments
 (0)