Skip to content

Commit

Permalink
Config option to disable logging to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
1A3Dev committed Jan 17, 2024
1 parent fafe14a commit ea42dd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class ConfigManager
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
public static ConfigElement<string> CSConsole_Assembly_Blacklist;
public static ConfigElement<string> Reflection_Signature_Blacklist;
public static ConfigElement<bool> Save_Logs;

// internal configs
internal static InternalConfigHandler InternalHandler { get; private set; }
Expand Down Expand Up @@ -140,6 +141,10 @@ private static void CreateConfigElements()
"Seperate signatures with a semicolon ';'.\r\n" +
"For example, to blacklist Camera.main, you would add 'UnityEngine.Camera.main;'",
"");

Save_Logs = new("Save Logs To Disk",
"Should the log files be saved to disk?",
false);
}
}
}
5 changes: 3 additions & 2 deletions src/UI/Panels/LogPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private void SetupIO()
File.Delete(files[i]);
}

File.WriteAllLines(CurrentStreamPath, Logs.Select(it => it.message).ToArray());
if (ConfigManager.Save_Logs.Value)
File.WriteAllLines(CurrentStreamPath, Logs.Select(it => it.message).ToArray());
}

// Logging
Expand All @@ -82,7 +83,7 @@ public static void Log(string message, LogType type)
{
Logs.Add(new LogInfo(message, type));

if (CurrentStreamPath != null)
if (CurrentStreamPath != null && ConfigManager.Save_Logs.Value)
File.AppendAllText(CurrentStreamPath, '\n' + message);

if (logScrollPool != null)
Expand Down

0 comments on commit ea42dd8

Please sign in to comment.