I have this kind of code, with purpose is to wrap UnityEngine.Debug.Log
so I can disable them all on production also so that I can look/filter up later.
using System;
public enum LogType
{
DEBUG,
CRITICAL
}
public class LogHelper
{
public static void Log(LogType lt, string format, params object[] objs)
{
if (lt == LogType.CRITICAL)
{
// StackTrace st = new StackTrace(new StackFrame(true));
// Console.WriteLine(" Stack trace for current level: {0}", st.ToString());
// StackFrame sf = st.GetFrame(0);
// Console.WriteLine(" File: {0}", sf.GetFileName());
// Console.WriteLine(" Method: {0}", sf.GetMethod().Name);
// Console.WriteLine(" Line Number: {0}", sf.GetFileLineNumber());
// Console.WriteLine(" Column Number: {0}", sf.GetFileColumnNumber());
}
// TODO: write to /tmp file too
UnityEngine.Debug.Log("[" + lt + "] " + String.Format(format, objs));
}
public static void Critical(string format, params object[] objs)
{
Log(LogType.CRITICAL,format, objs);
}
public static void Debug(string format, params object[] objs)
{
Log(LogType.DEBUG,format, objs);
}
}
The problem is, when i call those LogHelper.Debug("something")
, the Unity Editor's Log when double clicked will go to that code (one that calls UnityEngine.Debug.Log
) instead of the source that call that LogHelper.Debug
. How to make it show the caller instead of the LogHelper
when I doubleclick the log?