Open MikeSchulze opened 4 years ago
I think this issue is due to get_stack() not working on any thread other than the main thread.
It also does that in builds, I wonder if it's for the same reason.
Since push_error
doesn't include the stack trace in the .log files I wrote a logger that would do it using get_stack()
, but doesn't seem to be possible, which makes the .log files less useful.
func log_error(message: String) -> void:
if OS.has_feature("editor"):
push_error(message)
else:
# Not running from editor, so create an error
# message that actually shows up in the logs
var stack: Array = get_stack()
var error: String = "ERROR: %s" % message
stack.pop_front() # Remove the "log_error" call itself from the stack
for point in stack:
error += "\n at %s:%s - %s" % [point.source, point.line, point.function]
printerr(error)
Suddenly it makes sense why push_error
doesn't log the stack trace.
Godot version: Godot Engine v3.2.2.stable.mono.official (c) 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors.
OS/device including version: Windows 10
Issue description: I want to use get_stack() in my editor plugin to show line numbers of failing tests. When call 'get_stack()' inside running editor plugin it returns a empty array
Steps to reproduce:
func _enter_tree(): prints("_enter_tree", get_stack())
_enter_tree []