Please disclose if any significant portion of your mod was created 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 LogSpamFilter v1.2.7
BepInEx/plugins/LogSpamFilter/LogSpamFilter.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [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 LogSpamFilter { [BepInPlugin("yourname.logspamfilter", "Log Spam Filter", "1.2.7")] public class Plugin : BaseUnityPlugin { private const string PluginVersion = "1.2.7"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { BepInExListenerFilter.Install(); Harmony.CreateAndPatchAll(typeof(DebugLogPatches), "yourname.logspamfilter"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Log Spam Filter loaded. Version: 1.2.7"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Changelog: Expanded spam suppression for Stingray, HoarderBug, Bracken, Cadaver, MouthDog, OpenBodyCams, rope, targeting, goUp, spawn planner, BoxCollider, and audio spatializer spam."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to patch logging: {arg}"); } } } internal static class BepInExListenerFilter { private sealed class FilteringLogListener : ILogListener, IDisposable { private readonly ILogListener _inner; public FilteringLogListener(ILogListener inner) { _inner = inner; } public void LogEvent(object sender, LogEventArgs eventArgs) { if (eventArgs == null || !SpamRules.ShouldBlock(eventArgs.Data)) { _inner.LogEvent(sender, eventArgs); } } public void Dispose() { ((IDisposable)_inner).Dispose(); } } private static bool _installed; public static void Install() { if (_installed) { return; } List<ILogListener> list = Logger.Listeners.ToList(); if (list.Count == 0) { _installed = true; return; } Logger.Listeners.Clear(); foreach (ILogListener item in list) { Logger.Listeners.Add((ILogListener)(object)new FilteringLogListener(item)); } _installed = true; } } internal static class SpamRules { private static readonly string[] StartsWithRules = new string[108] { "name 1 float:", "Start game A", "Start game B", "Start game C", "Start game D", "Start game E", "Start game successful", "Stop special animation F", "Stop special animation G", "LOADING GAME!!!!!", "Waiting for all players to load!", "DropAllHeldItems called on player", "Puma: ", "PUMA AI ", "Got target player?:", "Tree state:", "Starting puma climb", "Set puma climbing up!", "Set puma tree mode to idle;", "Getting end target tree; hiding meter :", "Get end target tree : Player #", "puma: Trees nearby player #", "tree #", "Puma F 1", "Puma F 2", "Puma F 3", "Puma : Got EndTargetTree!!!", "Got target tree: ", "Got nav pos:", "Got dest ", "No target tree found!", "GetTargetTree ", "Puma dist to closest player;", "First node gotten:", "Checking node #", "Stalking nodes in use contains node #", "Path is intersected by line of sight", "Position distance from ", "mostOptimalDistance:", "Puma leaped; leap attempts:", "Puma leap; target tree:", "Num of trees in physics check with range ", "Adding tree '", "i:", "Puma: Unable to leap to tree ", "Set target tree to '", "Puma: Unable to relocate", "Puma Relocating! Set target tree to '", "Puma dropped from tree! Target tree:", "Attempted to drop but unable. Adding tree '", "Attempt drop. Relocate.", "Received tree climb RPC ", "Tree width:", "Dist:", "treeBottomPosition magnitude:", "Distance from startingPos to Target tree:", "Puma error: destination is far away from target tree.", "Puma: Tree has no capsule collider.", "Puma: Tree is too short off the ground.", "Puma: Attempted to remove tree '", "Checking Tree #", "Tree #", "Set GetTargetTree: Got target tree?:", "Stalking frozen.", "Hearing noise from ", "Send Stalk frozen RPC on local client!", "player knowledge ", "The puma is on its target tree!", "On end target tree:", "Time since hitting < 8!", "Whining audio playing?:", "Whining audio playing? B:", "slipperyFloor:", "push force magnitude:", "cloak speed lunge:", "Start whining audio!", "Add to anger meter called! amount to add:", "Increasing agent speed by ", "Baby bird distance to nest :", "Counting scream timer; timer:", "Setting position of ropes", "Targetable A", "goUp: ", "dog 'MouthDog(Clone)': Heard noise! Distance:", "Mouth dog targetPos 1:", "Mouth dog targetPos 2:", "Dog lastheardnoisePosition:", "Truck got collision from enemy; MouthDogModel", "Truck collision: is enemyCollisoinScript null? :", "Truck collision:", "HoarderBug(Clone): Setting target object and going towards it.", "hour: ", "Got enemy that will spawn for hour #", "Setting prob to 0; ", "Round manager: No more spawnable outside enemies.", "enemy rush index is ", "Hours: ", "Probability: ", "ADDING ENEMY #", "Adding 1 to power level, enemy: ", "Adding 1 to diversity level for enemy '", "BoxCollider does not support negative scale or size.", "The effective box size has been forced positive and is likely to give unexpected collision geometry.", "If you absolutely need to use negative scaling you can use the convex MeshCollider. Scene hierarchy path ", "Audio source failed to initialize audio spatializer.", "BigDoor(Clone) creating doorcode object in parent MapScreenUIWorldSpace", "Roundmanager: Refreshed OutsideAINodes list!: ", "No recording devices found" }; private static readonly string[] ExactRules = new string[10] { "D", "G", "H", "I", "J", "K", "L", "M", "T", "True, False" }; private static readonly string[] ContainsRules = new string[21] { "puma climb", "puma tree mode", "TargetTree", "EndTargetTree", "Puma dropped from tree", "Puma Relocating", "GetTargetTree", "ChooseClosestNodeToPositionPuma", "PathIsIntersectedByLineOfSightPuma", "Stalking frozen.", "seenByPumaThroughTrees:", "hidingQuickly:", "Hearing noise from ", "Send Stalk frozen RPC on local client!", "Attempt drop. Relocate.", "is seen by puma", "The puma is on its target tree!", "On end target tree:", "third-person and 0 cosmetics for ", "without a viewmodel replacement in ", "hit enemy MouthDog(Clone) with force of " }; public static bool ShouldBlock(object message) { if (message == null) { return false; } string text = message.ToString(); if (string.IsNullOrWhiteSpace(text)) { return false; } return ExactRules.Any((string exact) => string.Equals(text, exact, StringComparison.Ordinal)) || StartsWithRules.Any((string prefix) => text.StartsWith(prefix, StringComparison.Ordinal)) || ContainsRules.Any((string part) => text.IndexOf(part, StringComparison.Ordinal) >= 0); } public static bool ShouldBlockFormatted(string format, object[] args) { if (string.IsNullOrEmpty(format)) { return false; } string message; try { message = ((args != null && args.Length != 0) ? string.Format(format, args) : format); } catch { message = format; } return ShouldBlock(message); } } internal static class DebugLogPatches { [HarmonyPatch(typeof(Debug), "Log", new Type[] { typeof(object) })] [HarmonyPrefix] private static bool DebugLog_Object_Prefix(object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Debug), "Log", new Type[] { typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool DebugLog_ObjectContext_Prefix(object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Debug), "LogFormat", new Type[] { typeof(string), typeof(object[]) })] [HarmonyPrefix] private static bool DebugLogFormat_Prefix(string format, object[] args) { return !SpamRules.ShouldBlockFormatted(format, args); } [HarmonyPatch(typeof(Debug), "LogFormat", new Type[] { typeof(Object), typeof(string), typeof(object[]) })] [HarmonyPrefix] private static bool DebugLogFormat_Context_Prefix(Object context, string format, object[] args) { return !SpamRules.ShouldBlockFormatted(format, args); } [HarmonyPatch(typeof(Debug), "LogWarning", new Type[] { typeof(object) })] [HarmonyPrefix] private static bool DebugLogWarning_Object_Prefix(object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Debug), "LogWarning", new Type[] { typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool DebugLogWarning_ObjectContext_Prefix(object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object) })] [HarmonyPrefix] private static bool DebugLogError_Object_Prefix(object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool DebugLogError_ObjectContext_Prefix(object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "Log", new Type[] { typeof(LogType), typeof(object) })] [HarmonyPrefix] private static bool LoggerLog_LogTypeObject_Prefix(LogType logType, object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "Log", new Type[] { typeof(LogType), typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool LoggerLog_LogTypeObjectContext_Prefix(LogType logType, object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "Log", new Type[] { typeof(object) })] [HarmonyPrefix] private static bool LoggerLog_Object_Prefix(object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "Log", new Type[] { typeof(string), typeof(object) })] [HarmonyPrefix] private static bool LoggerLog_TagObject_Prefix(string tag, object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "Log", new Type[] { typeof(string), typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool LoggerLog_TagObjectContext_Prefix(string tag, object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "LogFormat", new Type[] { typeof(LogType), typeof(string), typeof(object[]) })] [HarmonyPrefix] private static bool LoggerLogFormat_LogType_Prefix(LogType logType, string format, object[] args) { return !SpamRules.ShouldBlockFormatted(format, args); } [HarmonyPatch(typeof(Logger), "LogFormat", new Type[] { typeof(LogType), typeof(Object), typeof(string), typeof(object[]) })] [HarmonyPrefix] private static bool LoggerLogFormat_LogTypeContext_Prefix(LogType logType, Object context, string format, object[] args) { return !SpamRules.ShouldBlockFormatted(format, args); } [HarmonyPatch(typeof(Logger), "LogWarning", new Type[] { typeof(string), typeof(object) })] [HarmonyPrefix] private static bool LoggerLogWarning_TagObject_Prefix(string tag, object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "LogWarning", new Type[] { typeof(string), typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool LoggerLogWarning_TagObjectContext_Prefix(string tag, object message, Object context) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "LogError", new Type[] { typeof(string), typeof(object) })] [HarmonyPrefix] private static bool LoggerLogError_TagObject_Prefix(string tag, object message) { return !SpamRules.ShouldBlock(message); } [HarmonyPatch(typeof(Logger), "LogError", new Type[] { typeof(string), typeof(object), typeof(Object) })] [HarmonyPrefix] private static bool LoggerLogError_TagObjectContext_Prefix(string tag, object message, Object context) { return !SpamRules.ShouldBlock(message); } } }