mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using BepInEx.Logging;
|
|
using UnityEngine;
|
|
|
|
namespace BepInEx.IL2CPP.Logging
|
|
{
|
|
public class IL2CPPUnityLogSource : ILogSource
|
|
{
|
|
public IL2CPPUnityLogSource()
|
|
{
|
|
Application.s_LogCallbackHandler = new Action<string, string, LogType>(UnityLogCallback);
|
|
}
|
|
|
|
public string SourceName { get; } = "Unity";
|
|
|
|
public event EventHandler<LogEventArgs> LogEvent;
|
|
|
|
public void Dispose() { }
|
|
|
|
public void UnityLogCallback(string logLine, string exception, LogType type)
|
|
{
|
|
var level = type switch
|
|
{
|
|
LogType.Error => LogLevel.Error,
|
|
LogType.Assert => LogLevel.Debug,
|
|
LogType.Warning => LogLevel.Warning,
|
|
LogType.Log => LogLevel.Message,
|
|
LogType.Exception => LogLevel.Error,
|
|
_ => LogLevel.Message
|
|
};
|
|
LogEvent?.Invoke(this, new LogEventArgs(logLine, level, this));
|
|
}
|
|
}
|
|
}
|