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

Extra debug details possible? #13335

Closed
RaXaR opened this issue Nov 27, 2017 · 5 comments
Closed

Extra debug details possible? #13335

RaXaR opened this issue Nov 27, 2017 · 5 comments

Comments

@RaXaR
Copy link
Contributor

RaXaR commented Nov 27, 2017

I would like to know if it's possible to print the script + line number along with a print(something) call?

An example output of this function could be:

> Line:   16| .\scripts\mobs\mob_base.gd | "was hit!"
> Line:  172| .\scripts\mobs\mob_base.gd | 255
> Line:  4572| .\scripts\player\player.gd
> "This was a particularly long string so it printed out on a new line instead of wrapping."

The intent is of course to make it easier to trace debug output during development. If you forgot a random print(number) somewhere it can be pretty tedious to find it. It also helps to keep track of what's going on and where when you know where the printouts come from.

Another expansion could be to allow debug printing arrays and objects with clean and readable formatting. Here's an example of an array debug in one of my PHP scripts:

Line:   34| ...\controllers\somefile.php
Array
(
    [items] => Array
        (
            [0] => stdClass Object
                (
                    [item_id] => 126
                    [client_id] => 8
                    [note] => Some randome note.
                )

            [1] => stdClass Object
                (
                    [item_id] => 125
                    [client_id] => 22
                    [note] => Some randome note again.
                )
...

As you can see it's a lot easier to follow what's going one here. What are your thoughts?

@Zireael07
Copy link
Contributor

Script and line number for print calls would be a nice idea indeed.

@mhilbrunner
Copy link
Member

Was discussed in #3884 (although that is badly named and thus hard to find). It was said there that it wouldn't be that hard to do and even tagged as a junior job, however, I have no idea where to start on this.

Maybe somebody can make some suggestion on how this could be done?
@bojidar-bg?

@bojidar-bg
Copy link
Contributor

There is a print_stack function, which might prove useful for that...

One day we should probably implement the line numbering proposed in #3884 as well 😃

@RaXaR
Copy link
Contributor Author

RaXaR commented Nov 27, 2017

print_stack() has all the info in it that I would want. But it doesn't take a parameter nor returns a string for custom parsing .. kind of limits it's usefulness.

Could it perhaps be get a variant that returns the string that is printed to console instead?
EDIT: or even take a boolean flag "return_string"

@mhilbrunner
Copy link
Member

Implemented by #18976

@akien-mga akien-mga added this to the 3.1 milestone Jul 3, 2018
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

5 participants