Make preloader logger respect the log level

This commit is contained in:
ghorsington committed 2020-06-13 19:59:01 +03:00
1 parent dfba4f0a03
commit 4b844b4dab
1 file changed
+9
@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using BepInEx.Configuration;
using BepInEx.Logging; using BepInEx.Logging;
namespace BepInEx.Preloader namespace BepInEx.Preloader
@@ -29,6 +30,9 @@ namespace BepInEx.Preloader
public void LogEvent(object sender, LogEventArgs eventArgs) public void LogEvent(object sender, LogEventArgs eventArgs)
{ {
if ((eventArgs.Level & ConfigConsoleDisplayedLevel.Value) == 0)
return;
LogEvents.Add(eventArgs); LogEvents.Add(eventArgs);
ConsoleManager.SetConsoleColor(eventArgs.Level.GetConsoleColor()); ConsoleManager.SetConsoleColor(eventArgs.Level.GetConsoleColor());
@@ -56,6 +60,11 @@ namespace BepInEx.Preloader
LoggerSource = null; LoggerSource = null;
} }
} }
private static readonly ConfigEntry<LogLevel> ConfigConsoleDisplayedLevel = ConfigFile.CoreConfig.Bind(
"Logging.Console","LogLevels",
LogLevel.Fatal | LogLevel.Error | LogLevel.Message | LogLevel.Info,
"Which log levels to show in the console output.");
} }
public class PreloaderConsoleSource : TextWriter, ILogSource public class PreloaderConsoleSource : TextWriter, ILogSource