Godot: searching for a print

Created on 29 Feb 2016  路  22Comments  路  Source: godotengine/godot

I think I am not the only one who is using print for debugging but at some point you have so many "print" and don't know where they are coming from so maybe this could be implemented.

42   printl("something happened")

Output:
"something happened - path/to/script.gd line 42"

feature proposal junior job gdscript

Most helpful comment

Ok, I think I have a better idea, what about printing the line number always, similar to chromium's console (maybe appearing like a link):
image

All 22 comments

That could be helpful. +1

do better prints :)

:+1: - Plus, it doesn't seem too hard to do

@akien-mga ~ You can tag this with "enhancement"/"feature proposal" + "topic:gdscript" + "junior job" + (only if you think it needs it) "discussion"

Is anybody assigned this task? Can I try to do it?

@fumgames ~ I'm not going to find time anytime soon, and I guess @nunodonato and @freemanfromgodotengine haven't started with it either... so, just go!

I hadn't the minor intention of doing it... I'm sorry but it sounds like a bad feature that will just motivate people to do bad debugs. I can't find any positive things about it

@nunodonato ~ I think that this might be rather helpful for _some_ game developers, plus, it doesn't bloat the engine even a bit.

@bojidar-bg if you can type myprintfunc("whatever") you can also print("line 20"). seems unnecessary bloat when you should be learning how to properly debug your code. I just can't find a good enough reason to support this "feature", but whatever :)

@nunodonato ~ I look at it the other way -- there aren't many reasons not too add it :smile:

@bojidar-bg that's true.. but if you use that criteria all the time, you end up with a bloated project with stuff that is useful in some remote cases. "Perfection is not when there is nothing else to add, but when there is nothing left to take away" ;)

@nunodonato ~ uh, that's true too... but having to do formatting stuff each time is boring...

On a big projects with many lines you can't expect someone to remember each print, specially when you work in a team. Searching for a print or change the print line number each time you change the code is big waste of time.

The main interest I would see in such a feature is if you want to actually output relevant debug info in logs for your players, so that they can report to you where your game did not behave correctly. Might also be useful for the team directly if it's a debug option (btw having prints everywhere that you don't need is IMO pointless, but if they are triggered by a "debug=true" option, then it becomes interesting to see how the calls are made from one file/line to the other).

So for me such a function would be mostly useful in:

func print_debug(string):
    if debug:
        printl(string)

Though of course, as I write it, I realise that it wouldn't work as it would likely print the line where this helper function is defined XD

@akien-mga what's the problem in implementing function "print_debug" which will work only if debug is active?) I mean, you shouldn't define your own "print_debug", just use the internal

:D , I also thought about the debug flag. Maybe we could later do a plugin where you have a list of all prints and can say I don't want to see the debug informations of Node X or line X so you don't have to use (un)comments all the time...

I think printd is still free maybe it is better than printl

Yeah, I guess being able to disable this kind of prints via project settings would be awesome.

Ok, I think I have a better idea, what about printing the line number always, similar to chromium's console (maybe appearing like a link):
image

How about implementing a default argument "debug" or the function print, which would print the line numbers and other details only if the debug argument is set to True?

For instance,
print("This is some debugging info", debug=True) --> for printing the line numbers and other info

@AdityaCheruvu print() is a vararg function, if you pass multiple arguments it'll print them all. Also GDScript doesn't have named arguments.

With #18966 and #18976 merged, I think this can be closed.

Yeah, you can use print_debug() now.

Was this page helpful?
0 / 5 - 0 ratings