Skip to content

Commit

Permalink
Merge pull request #7 from 1A3Dev/disk-log-toggle
Browse files Browse the repository at this point in the history
Config Option To Disable Log Files
  • Loading branch information
yukieiji authored Jan 18, 2024
2 parents fafe14a + 9ee62ef commit 2268142
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 @@ -22,6 +22,7 @@ public static class ConfigManager
public static ConfigElement<string> Default_Output_Path;
public static ConfigElement<string> DnSpy_Path;
public static ConfigElement<bool> Log_Unity_Debug;
public static ConfigElement<bool> Log_To_Disk;
public static ConfigElement<UIManager.VerticalAnchor> Main_Navbar_Anchor;
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
Expand Down Expand Up @@ -121,6 +122,10 @@ private static void CreateConfigElements()
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
false);

Log_To_Disk = new("Log To Disk",
"Should UnityExplorer save log files to the disk?",
true);

World_MouseInspect_Keybind = new("World Mouse-Inspect Keybind",
"Optional keybind to being a World-mode Mouse Inspect.",
KeyCode.None);
Expand Down
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.Log_To_Disk.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.Log_To_Disk.Value)
File.AppendAllText(CurrentStreamPath, '\n' + message);

if (logScrollPool != null)
Expand Down

0 comments on commit 2268142

Please sign in to comment.