Flexy.Log: Start Guide
Configure logging, route Debug calls, and filter output by source file.
How It Works
- Reroute all calls to
Debug.LogwithFlexy.Log.Debugand handle logging in Allocation Free way
How To use
- Enable C#10 support in project settings (add
-langversion:10to additional compiler arguments) - Add line
global using Debug = Flexy.Log.Debug;in one cs file in project to reroute calls - Set log level as usual:
Debug.unityLogger.filterLogType = LogType.Warning; - Set log filtering level by:
Debug.Filter!.FilterFrom = LogType.Warning; - Allow logs from file for filter by
Debug.Filter?.AllowLogOnPath ("./PathToFile.cs", "MethodName");Debug.Filter?.AllowLogOnPath ("./Assets/!Game/!Code/Settings/Window_GameSettings.cs", "Update");Debug.Filter?.AllowLogOnPath ("./Packages/fun.flexy.core/Runtime/GameContexts/GameContext.cs");
Additional
UnityEngine.LogFormat always allocates!
To prohibit this, you can remove log format methods by adding define FLEXY_LOG__DISABLE_LOG_FORMAT to project settings
Then fix errors in all places where you use Debug.LogFormat
Technical Details
- Uses modern C# features (C# 10)
- Tested with Unity 2022.3 through Unity 6.3
See the Scripting API for Debug and LogFilter.