Decompiled source of QuietLogs v1.0.0

plugins/ElfDevelop.QuietLogs.dll

Decompiled 13 hours ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuietLogs
{
	[ContentWarningPlugin("ElfDevelop.QuietLogs", "1.0.0", true)]
	[BepInPlugin("ElfDevelop.QuietLogs", "QuietLogs", "1.0.0")]
	public class QuietLogsPlugin : BaseUnityPlugin
	{
		private const string DbsPrefix = "[DbsContentApi] ";

		private static string[] hiddenMessages = Array.Empty<string>();

		private static int hidden;

		internal static ManualLogSource Logger { get; private set; } = null;

		private void Awake()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			hiddenMessages = (from s in ((BaseUnityPlugin)this).Config.Bind<string>("DbsContentApi", "HiddenMessages", "Could not find material:|Unique material names:", "DB's Content API messages to hide: parts of the message text, separated by |. Empty shows everything.").Value.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim() into s
				where s.Length > 0
				select s).ToArray();
			new Harmony("ElfDevelop.QuietLogs").Patch((MethodBase)AccessTools.Method(typeof(UnityLogSource), "OnUnityLogMessageReceived", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(QuietLogsPlugin), "SkipHidden", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Logger.LogInfo((object)("QuietLogs 1.0.0 has loaded! Hiding DB's Content API messages containing: " + string.Join(", ", hiddenMessages)));
		}

		private static bool SkipHidden(string message)
		{
			if (message == null || !message.StartsWith("[DbsContentApi] ", StringComparison.Ordinal))
			{
				return true;
			}
			if (!hiddenMessages.Any((string h) => message.IndexOf(h, "[DbsContentApi] ".Length, StringComparison.Ordinal) >= 0))
			{
				return true;
			}
			if (hidden++ == 0)
			{
				Logger.LogInfo((object)"Hiding DB's Content API material messages (set in ElfDevelop.QuietLogs.cfg)");
			}
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}