123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Diagnostics;
- namespace BepInEx.Logger
- {
- public class LoggerTraceListener : TraceListener
- {
- public BaseLogger Logger;
- public LoggerTraceListener(BaseLogger logger)
- {
- Logger = logger;
- }
- public override void Write(string message)
- {
- Logger.Write(message);
- }
- public override void WriteLine(string message)
- {
- Logger.WriteLine(message);
- }
- public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
- => TraceEvent(eventCache, source, eventType, id, string.Format(format, args));
- public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
- {
- LogLevel level;
- switch (eventType)
- {
- case TraceEventType.Critical:
- level = LogLevel.Fatal;
- break;
- case TraceEventType.Error:
- level = LogLevel.Error;
- break;
- case TraceEventType.Warning:
- level = LogLevel.Warning;
- break;
- case TraceEventType.Information:
- level = LogLevel.Info;
- break;
- case TraceEventType.Verbose:
- default:
- level = LogLevel.Debug;
- break;
- }
- Logger.Log(level, $"{source} : {message}");
- }
- }
- }
|