Fix crash when logging pre-formatted messages
This commit is contained in:
@@ -131,7 +131,15 @@ namespace Torch.Managers
|
|||||||
|
|
||||||
private static bool PrefixLogFormatted(MyLog __instance, MyLogSeverity severity, string format, object[] args)
|
private static bool PrefixLogFormatted(MyLog __instance, MyLogSeverity severity, string format, object[] args)
|
||||||
{
|
{
|
||||||
_log.Log(LogLevelFor(severity), PrepareLog(__instance).AppendFormat(format, args));
|
// Sometimes this is called with a pre-formatted string and no args
|
||||||
|
// and causes a crash when the format string contains braces
|
||||||
|
var sb = PrepareLog(__instance);
|
||||||
|
if (args != null && args.Length > 0)
|
||||||
|
sb.AppendFormat(format, args);
|
||||||
|
else
|
||||||
|
sb.Append(format);
|
||||||
|
|
||||||
|
_log.Log(LogLevelFor(severity), sb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user