Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stack trace information to push_error and push_warning on terminal output #1605

Closed
Rubonnek opened this issue Oct 4, 2020 · 1 comment

Comments

@Rubonnek
Copy link
Member

Rubonnek commented Oct 4, 2020

Describe the project you are working on:
N/A

Describe the problem or limitation you are having in your project:
For a while now I tend to keep an eye on the terminal where Godot was executed rather than the Debugger in the Editor, since it's easier to catch leaks caught by ObjectDB in my projects there, and also Godot prints almost everything I need there too.

It's bugging me now that stack traces are not printed on the terminal that executed Godot when push_warning and push_error execute, even though these can be seen on the Debugger in the Editor.

Also stack trace information is not available when executing a script with godot -s. Trace information should be available there too.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Stack trace information is added to push_error and push_warning, and perhaps also moved into a new logging system.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

Running the following with godot -s:

#!/usr/bin/godot -s
extends SceneTree

func _init():
        push_error("test")
        quit()

Would yield the following:

ERROR: call: test
   At: res://test.gd:5:_init()
   At: modules/gdscript/gdscript_functions.cpp:807.

Instead of what it currently yields which is:

ERROR: call: test
   At: modules/gdscript/gdscript_functions.cpp:807.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

This will be used often by anyone that's logging / debugging code.

Yes, it can be worked around when using the Editor, since stack trace information can be added easily with print_stack(), for example:

extends Node

func _init():
        push_error("test")
        print_stack()

This, however, does not work when using godot -s as previously stated.

Is there a reason why this should be core and not an add-on in the asset library?:

These changes should be in core as the ERR_PRINT and WARN_PRINT macros may need to be changed to something else and the GDScriptLanguage singleton initialization moved so that stack trace information is also available when running scripts with godot -s.

Also, given the proposals to have a built-in logging system such as #919, and #1378, it may be worth moving the stack traces to such logging system.

@Calinou
Copy link
Member

Calinou commented Oct 9, 2020

Duplicate of #963.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants