Debug.Log Override?

Is it possible to change the Debug.Log void and if so is anything like this close:

using UnityEngine;
using System.Collections;

public class Debug : MonoBehaviour {
	public override void Log (string debugMsg) {
		base.Log ();
		var example = "Hey";
	} 
}

Debug.Log is a static method, so you can’t override it.
You also can’t create Static Extension methods, Extension methods only work on instances.

You could create your own Logger class with it’s own Static logging functionality which has the improvements you want. There are even some of these on the asset store.

I’m not sure what you’re trying to do with that example.

FYI RegisterLogCallback is now deprecated.

Now, you want to use the event:

Application.logMessageReceived += HandlerMethodName;

The handler signature must be:
HandlerMethodName(string logString, string stackTrace, LogType type)

I found the bug, you have to call Application.RegisterLogCallback in the same frame as the Debug.Log is called :slight_smile: