Jump to content

HCI87239432

Verified Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by HCI87239432

  1. Good News!

    A simple but effective solution is to override the default Unity's Debug.Log ILogHandler with your own.

    Attach this script to a game object in the scene and adjust the keywords according to your needs 🙂

     

    using System;
    using UnityEngine;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    #if UNITY_EDITOR
        [InitializeOnLoad]
    #endif
        public class LogHandlerManager : MonoBehaviour
        {
            private static string[] keywords ={
                "Wave",
                "Essense",
                "PackageInfo()", 
                "InteractionModeManagerSettings"
            };
    
            private static LogHandler logHandler; 
    
            static LogHandlerManager()
            {
                logHandler = new LogHandler();
                logHandler.keywords = keywords;
                
                Debug.unityLogger.logHandler = logHandler;
            }
        }
    
    public class LogHandler : ILogHandler
    {
        public string[] keywords;
    
        private static ILogHandler unityLogHandler = Debug.unityLogger.logHandler;
    
        public void LogException(Exception exception, UnityEngine.Object context)
        {
            unityLogHandler.LogException(exception, context);
        }
    
        public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args)
        {
            if (Application.isEditor)
            {
                foreach (string formatString in args)
                foreach (var keyword in keywords)
                    if (formatString.Contains(keyword, StringComparison.OrdinalIgnoreCase))
                        return;
            }
    
            unityLogHandler.LogFormat(logType, context, format, args);
        }
    }

     

×
×
  • Create New...