Skip to content

Commit

Permalink
Switched log wrapping to use stringbuilder to reduce log overflow (#68)
Browse files Browse the repository at this point in the history
* Switched log wrapping to use stringbuilder to reduce log overflow
  • Loading branch information
SimonDarksideJ authored Nov 11, 2024
1 parent 833faf9 commit 6b1214c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Runtime/Logging/StaticLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class StaticLogger

#region Private Properties
private static StringBuilder sb = new StringBuilder();
private static StringBuilder lf = new StringBuilder();
private static int logIndex = 0;
private static FilterLogType currentLogFilter = FilterLogType.All;
private static bool pauseLog = false;
Expand Down Expand Up @@ -81,15 +82,19 @@ public static void Log(string message, LogType logType = LogType.Log, bool appLo
{
if (!appLog)
{
if (WrapLog) { Console.WriteLine(WrapTemplate); }
Console.WriteLine(message);
if (WrapLog) { Console.WriteLine(WrapTemplate); }
if (WrapLog)
{
lf.Clear();
lf.AppendLine(WrapTemplate);
lf.AppendLine(message);
lf.AppendLine(WrapTemplate);
}

Console.WriteLine(WrapLog ? lf.ToString() : message);

if (DebugMode)
{
if (WrapLog) { Debug.LogFormat(logType, includeStackTrace ? LogOption.None : LogOption.NoStacktrace, null, WrapTemplate); }
Debug.LogFormat(logType, includeStackTrace ? LogOption.None : LogOption.NoStacktrace, null, message);
if (WrapLog) { Debug.LogFormat(logType, includeStackTrace ? LogOption.None : LogOption.NoStacktrace, null, WrapTemplate); }
Debug.LogFormat(logType, includeStackTrace ? LogOption.None : LogOption.NoStacktrace, null, WrapLog ? lf.ToString() : message);
}
return;
}
Expand Down

0 comments on commit 6b1214c

Please sign in to comment.