Write to Unity log only if console is disabled

Rebase of 03e82e1
This commit is contained in:
Bepis committed 2020-11-06 01:15:54 +11:00
1 parent 574077c23c
commit bd64d2d398
1 file changed
+12 -2
+12 -2
View File
@@ -3,6 +3,7 @@ using BepInEx.Logging;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using BepInEx.Bootstrap;
using BepInEx.Preloader.Core.Logging;
using BepInEx.Unity.Logging;
@@ -49,10 +50,11 @@ namespace BepInEx.Unity.Bootstrap
protected override void InitializeLoggers()
{
Logger.Listeners.Add(new UnityLogListener());
base.InitializeLoggers();
// Write to Unity logs directly only if console is not present (or user explicitly wants to)
if (ConfigWriteToUnityLog.Value || !ConsoleManager.ConsoleActive)
Logger.Listeners.Add(new UnityLogListener());
if (Utility.CurrentPlatform != Platform.Windows)
{
@@ -83,6 +85,14 @@ namespace BepInEx.Unity.Bootstrap
true,
"Enables showing unity log messages in the BepInEx logging system.");
private static readonly ConfigEntry<bool> ConfigWriteToUnityLog = ConfigFile.CoreConfig.Bind(
"Logging", "WriteToUnityLog",
false,
new StringBuilder()
.AppendLine("Enables writing log messages to Unity's log system")
.AppendLine("NOTE: By default, Unity already writes BepInEx console output to Unity logs")
.Append("Use this setting only if no BepInEx log messages are present in Unity's output_log").ToString());
private static readonly ConfigEntry<bool> ConfigDiskWriteUnityLog = ConfigFile.CoreConfig.Bind(
"Logging.Disk", "WriteUnityLog",
false,