Skip to content

Commit

Permalink
Merge pull request #414 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.9.14
  • Loading branch information
Aragas authored Oct 2, 2024
2 parents 18d8759 + bc7fb7c commit 2c04bdc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
4 changes: 2 additions & 2 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<BaseGameVersion>1.0.0</BaseGameVersion>
<!--Module Version-->
<Version>2.9.13</Version>
<Version>2.9.14</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand All @@ -18,7 +18,7 @@
<BuildResourcesVersion>1.1.0.104</BuildResourcesVersion>
<BUTRSharedVersion>3.0.0.142</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.226</BUTRModuleManagerVersion>
<CrashReportVersion>14.0.0.88</CrashReportVersion>
<CrashReportVersion>14.0.0.91</CrashReportVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 2.9.14
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Fixed a possible crash related to trace logging
* Updated crash reports path anonymization
---------------------------------------------------------------------------------------------------
Version: 2.9.13
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Better Wine detection
Expand Down
67 changes: 40 additions & 27 deletions src/Bannerlord.ButterLib/Logger/LoggerTraceListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,47 @@ private record ParseResult
// BLSE fixes that, but we might revert to string handling before BLSE is mandatory
private static ParseResult? Parse(ReadOnlySpan<char> str)
{
if (str.IndexOf(':') is var logLevelIdx && logLevelIdx == -1)
return null;

var sourceLogLevel = str.Slice(0, logLevelIdx);
var eventIdMessage = str.Slice(logLevelIdx + 1);

if (sourceLogLevel.LastIndexOf(' ') is var sourceIdx && sourceIdx == -1)
return null;
var process = sourceLogLevel.Slice(0, sourceIdx);
var logLevelStr = sourceLogLevel.Slice(sourceIdx + 1);

if (!Enum.TryParse<TraceEventType>(logLevelStr.ToString(), out var logLevel))
return null;

var eventIdIdx = eventIdMessage.IndexOf(':');
if (eventIdIdx == -1)
return null;
if (!int.TryParse(eventIdMessage.Slice(0, eventIdIdx).ToString(), out var eventId))
return null;
var message = eventIdMessage.Slice(eventIdIdx + 2);

return new ParseResult
try
{
if (str.IndexOf(':') is var logLevelIdx && logLevelIdx == -1)
return null;

var sourceLogLevel = str.Slice(0, logLevelIdx);
var eventIdMessage = str.Slice(logLevelIdx + 1);

if (sourceLogLevel.LastIndexOf(' ') is var sourceIdx && sourceIdx == -1)
return null;
var process = sourceLogLevel.Slice(0, sourceIdx);
var logLevelStr = sourceLogLevel.Slice(sourceIdx + 1);

if (!Enum.TryParse<TraceEventType>(logLevelStr.ToString(), out var logLevel))
return null;

var eventIdIdx = eventIdMessage.IndexOf(':');
if (eventIdIdx == -1)
return null;
if (!int.TryParse(eventIdMessage.Slice(0, eventIdIdx).ToString(), out var eventId))
return null;
var message = eventIdMessage.Slice(eventIdIdx + 2);

return new ParseResult
{
Process = process.ToString(),
Level = logLevel,
EventId = eventId,
Message = message.ToString()
};
}
catch (Exception e)
{
Process = process.ToString(),
Level = logLevel,
EventId = eventId,
Message = message.ToString()
};
return new ParseResult
{
Process = "UNKNOWN",
Level = TraceEventType.Error,
EventId = 0,
Message = $"Failed to parse log message: {str.ToString()}! Please report this issue to the ButterLib developers! Exception: {e}"
};
}
}


Expand Down

0 comments on commit 2c04bdc

Please sign in to comment.