How can I debug log without stack trace, while assert with stack trace (if assert fail)?
I have some ideas about minimizing the stack trace when using Debug.Log. But i don’t know how to completely disable it.
For example following script will allow you to log with a single line stack trace but it will do it with one update delay.
public class LoggerWithMinimizedStackTrace : MonoBehaviour {
private Queue<object> _logQueue = new Queue<object>();
public void Log(object message) {
_logQueue.Enqueue(message);
enabled = true;
}
void Update() {
while (_logQueue.Count > 0) {
Debug.Log(_logQueue.Dequeue());
}
enabled = false;
}
}
You can use Singelton pattern to save yourself from finding instance of this monobehaviour above.