Skip to content

Commit

Permalink
Improve time extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Loudbooks committed Sep 8, 2024
1 parent 70a2fac commit 405c060
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions loginspect/LogInspect/LogInspect/Modules/LogCommandModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ private string GeneratePageOne(string[] lines, int stacktraceAmount)
{
minecraftVersion = versionLines[0].Split("]").Last().Split(": ").Last();

timeCreated = lines[0].Split("]").First().Replace("[", "").Trim();
var timeCreatedMatch = LatestLogTimeCreatedRegex().Match(lines[0]);

if (timeCreatedMatch.Success)
{
timeCreated = timeCreatedMatch.Value;
}
}
else
{
Expand All @@ -146,8 +151,7 @@ private string GeneratePageOne(string[] lines, int stacktraceAmount)
{
minecraftVersion = versionLines[0].Split("--version, ").Last().Split(", ").First();

var secondLine = lines[1];
timeCreated = secondLine.Split(",").First();
timeCreated = lines[4].Split("]").First().Replace("[", "").Trim();
}
}

Expand Down Expand Up @@ -205,4 +209,7 @@ private string GeneratePageOne(string[] lines, int stacktraceAmount)

return string.Join("\n", newLines);
}

[GeneratedRegex(@"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}")]
private static partial Regex LatestLogTimeCreatedRegex();
}

0 comments on commit 405c060

Please sign in to comment.