Overriding Logs

You can override logs completely with your own methods. This can be done either via the custom inspector or C# scripting. Here is a C# example:

using UnityEngine;
using CatLog;

public class CustomLogBehaviour : MonoBehaviour
{
    private void Start()
    {
        // Modify the InfoLogAction property to change the behavior of the Log.Info method
        Log.Settings.Actions.InfoLogAction = CustomInfoLog;
        
        Log.Info("A message");
    }

    private void CustomInfoLog(string message, string sourceFilePath, int lineNumber)
    {
        // Custom behavior for the Log.Info method
        Debug.Log("[CUSTOM INFO LOG]: " + message);
    }
}

Now, whenever you call the Log.Info method, it will use the custom behavior defined in the CustomInfoLog method. For example:

Log.Info("This is a custom info log message");
//[CUSTOM INFO LOG]: This is a custom info log message

To remove the custom action you simply set it back to null again, then the default logging method will take over:

Log.Settings.Actions.InfoLogAction = null;
//[INFO] CustomLogBehaviour.cs[12]: A message

Last updated