Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AsyncLoggers Filter v1.1.2
BepInEx/patchers/AsyncLoggers.Filter.Preloader.dll
Decompiled 2 years agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using System.Threading; using AsyncLoggers.DBAPI; using AsyncLoggers.Filter.Preloader.Dependency; using AsyncLoggers.Filter.Preloader.Patches; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using Mono.Cecil; using MonoMod.RuntimeDetour; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("AsyncLoggers")] [assembly: IgnoresAccessChecksTo("LethalConfig")] [assembly: AssemblyCompany("AsyncLoggers.Filter.Preloader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+5757257b1081d38fb0d846ed01b648b18d750c99")] [assembly: AssemblyProduct("AsyncLoggers.Filter.Preloader")] [assembly: AssemblyTitle("AsyncLoggers.Filter.Preloader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 AsyncLoggers.Filter.Preloader { public class AsyncLoggersFilter { public static class PluginConfig { public class ModConfig { public ILogSource Source { get; private protected set; } public ConfigEntry<bool> EnabledConfig { get; } public bool Enabled { get; private protected set; } public ConfigEntry<LogLevel> LogLevelsConfig { get; } public LogLevel LogLevels { get; private protected set; } public ModConfig(ILogSource source, bool enabled, LogLevel logLevels) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Source = source; Enabled = enabled; LogLevels = logLevels; } internal ModConfig(ILogSource source) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) Source = source; string text = ""; if (source is UnityLogSource) { text = "\nWARNING: Filtering is done on BepInEx side, unity logs will still be written to unity logfile regardless of this config"; } string input = source.SourceName.Trim(); string text2 = Regex.Replace(input, "[\\n\\t\\\\\\'[\\]]", ""); EnabledConfig = Config.Bind<bool>(text2, "Enabled", true, new ConfigDescription("Allow mod to write logs" + text, (AcceptableValueBase)null, Array.Empty<object>())); EnabledConfig.SettingChanged += delegate { Enabled = EnabledConfig.Value; }; Enabled = EnabledConfig.Value; LogLevelsConfig = Config.Bind<LogLevel>(text2, "LogLevels", (LogLevel)63, new ConfigDescription("What levels to write" + text, (AcceptableValueBase)null, Array.Empty<object>())); LogLevelsConfig.SettingChanged += delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) LogLevels = LogLevelsConfig.Value; }; LogLevels = LogLevelsConfig.Value; if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddConfig(EnabledConfig); LethalConfigProxy.AddConfig<LogLevel>(LogLevelsConfig, requiresRestart: false); } } } internal static ConfigFile Config = null; public static readonly ConditionalWeakTable<ILogSource, ModConfig> ModConfigs = new ConditionalWeakTable<ILogSource, ModConfig>(); public static void Init() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown Config = new ConfigFile(Utility.CombinePaths(new string[2] { Paths.ConfigPath, "AsyncLoggers.Filter.cfg" }), true); _ = LethalConfigProxy.Enabled; ModConfigs.Add((ILogSource)(object)Log, new ModConfig((ILogSource)(object)Log, enabled: true, (LogLevel)63)); if (AsyncLoggerProxy.Installed) { ILogSource logger = AsyncLoggerProxy.GetLogger(); ModConfigs.Add(logger, new ModConfig(logger, enabled: true, (LogLevel)63)); } } public static void CleanAndSave() { ConfigFile config = Config; PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config, null); dictionary.Clear(); config.Save(); } } internal static readonly List<Hook> Hooks = new List<Hook>(); public static ManualLogSource Log { get; } = Logger.CreateLogSource("AsyncLoggers.Filter"); public static IEnumerable<string> TargetDLLs { get; } = new string[0]; public static void Patch(AssemblyDefinition assembly) { } public static void Initialize() { Log.LogInfo((object)"Preloader Started"); } public static void Finish() { PluginConfig.Init(); BepInExLogger.Init(); Log.LogInfo((object)"Preloader Finished"); } } } namespace AsyncLoggers.Filter.Preloader.Patches { internal static class BepInExLogger { private static readonly ConcurrentQueue<ILogSource> NewSources = new ConcurrentQueue<ILogSource>(); private static readonly SemaphoreSlim NewSourcesSemaphore = new SemaphoreSlim(0); private static void InitNewSources() { try { while (true) { NewSourcesSemaphore.Wait(1000); if (NewSources.TryDequeue(out var result) && !AsyncLoggersFilter.PluginConfig.ModConfigs.TryGetValue(result, out var _)) { AsyncLoggersFilter.Log.LogWarning((object)("Registering " + result.SourceName)); try { AsyncLoggersFilter.PluginConfig.ModConfigs.AddOrUpdate(result, new AsyncLoggersFilter.PluginConfig.ModConfig(result)); } catch (Exception arg) { AsyncLoggersFilter.Log.LogError((object)$"Exception Registering {result.SourceName}:\n{arg}"); } } } } catch (ThreadInterruptedException) { } } internal static void Init() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown AsyncLoggersFilter.Hooks.Add(new Hook((MethodBase)AccessTools.Method(typeof(Logger), "InternalLogEvent", (Type[])null, (Type[])null), (Delegate)new Action<Action<object, LogEventArgs>, object, LogEventArgs>(OnBepInExLogEvent), new HookConfig { Priority = -99 })); Thread thread = new Thread(InitNewSources) { IsBackground = true, Name = "AsyncLoggersFilter-DetectionThread" }; thread.Start(); } private static void OnBepInExLogEvent(Action<object, LogEventArgs> orig, object sender, LogEventArgs eventArgs) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (AsyncLoggersFilter.PluginConfig.ModConfigs.TryGetValue(eventArgs.Source, out var value)) { if (!value.Enabled || (eventArgs.Level & value.LogLevels) == 0) { return; } } else { NewSources.Enqueue(eventArgs.Source); NewSourcesSemaphore.Release(); } orig(sender, eventArgs); } } } namespace AsyncLoggers.Filter.Preloader.Dependency { public static class AsyncLoggerProxy { private static bool? _installed; private static bool? _enabled; public static bool Installed { get { if (_installed.HasValue) { return _installed.Value; } try { IsDbEnabled(); _installed = true; } catch (Exception) { _installed = false; return false; } return _installed.Value; } } public static bool Enabled { get { if (_enabled.HasValue) { return _enabled.Value; } try { _enabled = IsDbEnabled(); } catch (Exception) { _enabled = false; return false; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void WriteEvent(string source, string tag, string data, DateTime? timestamp = null) { SqliteLogger.WriteEvent(source, tag, data, timestamp); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void WriteData(string source, string tag, string data, DateTime? timestamp = null) { SqliteLogger.WriteData(source, tag, data, timestamp); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static bool IsDbEnabled() { return SqliteLogger.Enabled; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static int GetExecutionID() { return SqliteLogger.ExecutionId; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ILogSource GetLogger() { return (ILogSource)(object)AsyncLoggers.Log; } } public static class LethalConfigProxy { [Serializable] [CompilerGenerated] private sealed class <>c__10<T> where T : Enum { public static readonly <>c__10<T> <>9 = new <>c__10<T>(); public static CanModifyDelegate <>9__10_0; internal CanModifyResult <AddConfig>b__10_0() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return CanModifyResult.op_Implicit((false, "THIS IS A FLAG TYPE ENUM, EDITING CURRENTLY NOT SUPPORTED!")); } } private static bool? _enabled; public static Assembly PluginAssembly = Assembly.GetExecutingAssembly(); public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); _enabled = valueOrDefault; } return _enabled.Value; } } public static void ResetCache() { _enabled = null; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry<string> entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)new TextInputFieldConfigItem(entry, new TextInputFieldOptions { RequiresRestart = requiresRestart }), PluginAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry<bool> entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)new BoolCheckBoxConfigItem(entry, new BoolCheckBoxOptions { RequiresRestart = requiresRestart }), PluginAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry<float> entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)new FloatInputFieldConfigItem(entry, new FloatInputFieldOptions { RequiresRestart = requiresRestart }), PluginAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry<int> entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)new IntInputFieldConfigItem(entry, new IntInputFieldOptions { RequiresRestart = requiresRestart }), PluginAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig<T>(ConfigEntry<T> entry, bool requiresRestart = false) where T : Enum { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown EnumDropDownOptions val = new EnumDropDownOptions { RequiresRestart = requiresRestart }; object obj = <>c__10<T>.<>9__10_0; if (obj == null) { CanModifyDelegate val2 = () => CanModifyResult.op_Implicit((false, "THIS IS A FLAG TYPE ENUM, EDITING CURRENTLY NOT SUPPORTED!")); <>c__10<T>.<>9__10_0 = val2; obj = (object)val2; } ((BaseOptions)val).CanModifyCallback = (CanModifyDelegate)obj; LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)(object)new EnumDropDownConfigItem<T>(entry, val), PluginAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string description, string buttonText, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown LethalConfigManager.AddConfigItemForAssembly((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); }), PluginAssembly); } private static string GetPrettyConfigName<T>(ConfigEntry<T> entry) { return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(((ConfigEntryBase)entry).Definition.Key.Replace("_", " ")); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }
BepInEx/plugins/AsyncLoggers.Filter.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AsyncLoggers.DBAPI; using AsyncLoggers.Filter.Dependency; using AsyncLoggers.Filter.Preloader; using AsyncLoggers.Filter.Preloader.Dependency; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("AsyncLoggers.Filter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+5757257b1081d38fb0d846ed01b648b18d750c99")] [assembly: AssemblyProduct("AsyncLoggers.Filter")] [assembly: AssemblyTitle("AsyncLoggers.Filter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 AsyncLoggers.Filter { [BepInPlugin("mattymatty.AsyncLoggers.Filter", "AsyncLoggers.Filter", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class AsyncLoggersFilter : BaseUnityPlugin { internal static class PluginConfig { internal static void Init() { LethalConfigProxy.PluginAssembly = Assembly.GetExecutingAssembly(); LethalConfigProxy.ResetCache(); if (!LethalConfigProxy.Enabled) { return; } Log.LogInfo((object)"Registering LethalConfig options"); LethalConfigProxy.AddButton("Cleanup", "Clear old entries", "remove unused entries in the config file", "Clean&Save", (Action)PluginConfig.CleanAndSave); foreach (var (val3, val4) in (IEnumerable<KeyValuePair<ILogSource, ModConfig>>)PluginConfig.ModConfigs) { if (val4.EnabledConfig != null) { LethalConfigProxy.AddConfig(val4.EnabledConfig, false); } if (val4.LogLevelsConfig != null) { LethalConfigProxy.AddConfig<LogLevel>(val4.LogLevelsConfig, false); } } Log.LogInfo((object)"Registration completed"); } } public const string GUID = "mattymatty.AsyncLoggers.Filter"; public const string NAME = "AsyncLoggers.Filter"; public const string VERSION = "1.1.2"; internal static ManualLogSource Log; public static AsyncLoggersFilter INSTANCE { get; private set; } private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown INSTANCE = this; Log = ((BaseUnityPlugin)this).Logger; PluginConfig.ModConfigs.Add((ILogSource)(object)((BaseUnityPlugin)this).Logger, new ModConfig((ILogSource)(object)((BaseUnityPlugin)this).Logger, true, (LogLevel)63)); try { if (LobbyCompatibilityChecker.Enabled) { LobbyCompatibilityChecker.Init(); } if (AsyncLoggerProxy.Enabled) { AsyncLoggerProxy.WriteEvent("AsyncLoggers.Filter", "Awake", "Initializing"); } Log.LogInfo((object)"Initializing Configs"); PluginConfig.Init(); Log.LogInfo((object)"AsyncLoggers.Filter v1.1.2 Loaded!"); if (AsyncLoggerProxy.Enabled) { AsyncLoggerProxy.WriteEvent("AsyncLoggers.Filter", "Awake", "Finished Initializing"); } } catch (Exception ex) { Log.LogError((object)("Exception while initializing: \n" + ex)); } } } } namespace AsyncLoggers.Filter.Dependency { public static class AsyncLoggerProxy { private static bool? _enabled; public static bool Enabled { get { if (_enabled.HasValue) { return _enabled.Value; } try { _enabled = IsDbEnabled(); } catch (Exception) { _enabled = false; return false; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void WriteEvent(string source, string tag, string data, DateTime? timestamp = null) { SqliteLogger.WriteEvent(source, tag, data, timestamp); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void WriteData(string source, string tag, string data, DateTime? timestamp = null) { SqliteLogger.WriteData(source, tag, data, timestamp); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static bool IsDbEnabled() { return SqliteLogger.Enabled; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static int GetExecutionID() { return SqliteLogger.ExecutionId; } } public static class LobbyCompatibilityChecker { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Init() { PluginHelper.RegisterPlugin("mattymatty.AsyncLoggers.Filter", Version.Parse("1.1.2"), (CompatibilityLevel)2, (VersionStrictness)2); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }