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

searching for a print #3884

Closed
AlexHolly opened this issue Feb 29, 2016 · 22 comments
Closed

searching for a print #3884

AlexHolly opened this issue Feb 29, 2016 · 22 comments

Comments

@AlexHolly
Copy link
Contributor

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"

@freemanfromgodotengine
Copy link

That could be helpful. +1

@nunodonato
Copy link
Contributor

do better prints :)

@bojidar-bg
Copy link
Contributor

👍 - Plus, it doesn't seem too hard to do

@bojidar-bg
Copy link
Contributor

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

@vitvakatu
Copy link

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

@bojidar-bg
Copy link
Contributor

@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!

@nunodonato
Copy link
Contributor

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

@bojidar-bg
Copy link
Contributor

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

@nunodonato
Copy link
Contributor

@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 :)

@bojidar-bg
Copy link
Contributor

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

@nunodonato
Copy link
Contributor

@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" ;)

@bojidar-bg
Copy link
Contributor

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

@AlexHolly
Copy link
Contributor Author

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.

@akien-mga
Copy link
Member

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

@vitvakatu
Copy link

@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

@AlexHolly
Copy link
Contributor Author

: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

@bojidar-bg
Copy link
Contributor

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

@bojidar-bg
Copy link
Contributor

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

@AdityaCheruvu
Copy link

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

@vnen
Copy link
Member

vnen commented Feb 23, 2018

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

@chanon
Copy link
Contributor

chanon commented Jul 5, 2018

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

@vnen
Copy link
Member

vnen commented Jul 5, 2018

Yeah, you can use print_debug() now.

@vnen vnen closed this as completed Jul 5, 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

10 participants