Skip to content

Commit

Permalink
Added the ability to "Wrap" log messages managed by the logger to mak…
Browse files Browse the repository at this point in the history
…e them easier to identify in LogCat and Android debugging output (#63)
  • Loading branch information
SimonDarksideJ authored May 30, 2024
1 parent ed51b34 commit ea9215d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Runtime/Logging/StaticLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public static class StaticLogger
/// Should logs be written to the Unity debugger.
/// </summary>
public static bool DebugMode { get; set; }

/// <summary>
/// Should logs be wrapped in a template.
/// </summary>
public static bool WrapLog { get; set; }

/// <summary>
/// The template to wrap logs in.
/// </summary>
public static string WrapTemplate { get; set; } = $"----------{Application.productName} - {Application.version}----------";
#endregion Public Properties

#region Public Methods
Expand All @@ -71,10 +81,15 @@ 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 (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); }
}
return;
}
Expand Down

0 comments on commit ea9215d

Please sign in to comment.