Browse Source

Use HarmonyLogSource from BepInEx.Core instead of temporary IL2CPP version

Bepis 3 years ago
parent
commit
cfaa68d11d

+ 0 - 1
BepInEx.IL2CPP/BepInEx.IL2CPP.csproj

@@ -67,7 +67,6 @@
     <Compile Include="BasePlugin.cs" />
     <Compile Include="DoorstopEntrypoint.cs" />
     <Compile Include="EnvVars.cs" />
-    <Compile Include="HarmonyLogSource.cs" />
     <Compile Include="Hook\FastNativeDetour.cs" />
     <Compile Include="Hook\IL2CPPDetourMethodPatcher.cs" />
     <Compile Include="IL2CPPChainloader.cs" />

+ 0 - 46
BepInEx.IL2CPP/HarmonyLogSource.cs

@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using BepInEx.Configuration;
-using HarmonyLogger = HarmonyLib.Tools.Logger;
-
-namespace BepInEx.Logging
-{
-	internal class HarmonyLogSource : ILogSource
-	{
-		private static readonly ConfigEntry<HarmonyLogger.LogChannel> LogChannels = ConfigFile.CoreConfig.Bind(
-			"Harmony.Logger",
-			"LogChannels",
-			HarmonyLogger.LogChannel.Warn | HarmonyLogger.LogChannel.Error,
-			"Specifies which Harmony log channels to listen to.\nNOTE: IL channel dumps the whole patch methods, use only when needed!");
-
-		private static readonly Dictionary<HarmonyLogger.LogChannel, LogLevel> LevelMap = new Dictionary<HarmonyLogger.LogChannel, LogLevel>
-		{
-			[HarmonyLogger.LogChannel.Info] = LogLevel.Info,
-			[HarmonyLogger.LogChannel.Warn] = LogLevel.Warning,
-			[HarmonyLogger.LogChannel.Error] = LogLevel.Error,
-			[HarmonyLogger.LogChannel.IL] = LogLevel.Debug
-		};
-		
-		public HarmonyLogSource()
-		{
-			HarmonyLogger.ChannelFilter = LogChannels.Value;			
-			HarmonyLogger.MessageReceived += HandleHarmonyMessage;
-		}
-
-		private void HandleHarmonyMessage(object sender, HarmonyLib.Tools.Logger.LogEventArgs e)
-		{
-			if (!LevelMap.TryGetValue(e.LogChannel, out var level))
-				return;
-
-			LogEvent?.Invoke(this, new LogEventArgs(e.Message, level, this));
-		}
-
-		public void Dispose()
-		{
-			HarmonyLogger.MessageReceived -= HandleHarmonyMessage;
-		}
-
-		public string SourceName { get; } = "HarmonyX";
-		public event EventHandler<LogEventArgs> LogEvent;
-	}
-}

+ 0 - 1
BepInEx.IL2CPP/IL2CPPChainloader.cs

@@ -41,7 +41,6 @@ namespace BepInEx.IL2CPP
 
 		public override unsafe void Initialize(string gameExePath = null)
 		{
-			Logger.Sources.Add(new HarmonyLogSource());
 			PatchManager.ResolvePatcher += IL2CPPDetourMethodPatcher.TryResolve;
 
 			base.Initialize(gameExePath);