Flexy.Tools / Utils

Flexy.Log

Structured Unity logging with runtime filtering and allocation-free interpolation.

Overview

Structured, Customizable and Allocation free drop in replacement logging for Unity

Description

Docs | Forum


Extend logs in your projects

Easy replace logs in entire project with one line of code

And make them Reach, Filterable and Allocation free on string interpolation


Key Benefits

  • Almost free on disabled logs
  • Very low perf impact on enabled log filtering
  • Enable/Disable logs in files on demand without rebuild/redeploy

How It Works

  • Reroute all calls to `Debug.Log` with `Flexy.Log.Debug` and handle logging in Allocation Free way

How To use

  • Enable C#10 support in project settings (add -langversion:10 to 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");

Technical details

Require enable C# 10

Tested with Unity 2022.3 through Unity 6.3