12345678910111213141516171819202122232425262728293031323334 |
- using System.Collections.Generic;
- using BepInEx.Configuration;
- using BepInEx.Logging;
- namespace BepInEx.Preloader.Core.Logging
- {
- /// <summary>
- /// Log listener that listens to logs during preloading time and buffers messages for output in Unity logs later.
- /// </summary>
- public class PreloaderConsoleListener : ILogListener
- {
- /// <summary>
- /// A list of all <see cref="LogEventArgs"/> objects that this listener has received.
- /// </summary>
- public static List<LogEventArgs> LogEvents { get; } = new List<LogEventArgs>();
- /// <inheritdoc />
- public void LogEvent(object sender, LogEventArgs eventArgs)
- {
- if ((eventArgs.Level & ConfigConsoleDisplayedLevel.Value) == 0)
- return;
- LogEvents.Add(eventArgs);
- }
- private static readonly ConfigEntry<LogLevel> ConfigConsoleDisplayedLevel = ConfigFile.CoreConfig.Bind(
- "Logging.Console", "LogLevels",
- LogLevel.Fatal | LogLevel.Error | LogLevel.Warning | LogLevel.Message | LogLevel.Info,
- "Which log levels to show in the console output.");
- /// <inheritdoc />
- public void Dispose() { }
- }
- }
|