Should I use print() more often?

Warning: I just went on a (mostly) unfiltered rant here. While I did exclude profanity, I will just go on about my thoughts in no particular order. May be a nightmare for people with OCD

I’m not going to put this in my organized format that I would otherwise like to stick with primarily due to the fact that… I don’t know how. This entire post can pretty much be boiled down to the topic name: Should I use the print(**args) method more often?
Primarily, I feel that printing would be good for notifying me that something has happened post-release. That was most likely a poor explanation, so I guess a more direct example would be for loading map data, achievements for sure, maybe an important kill count, some data comparison for locked doors, etc. Maybe even a way for more advanced players to see their technical mistakes under specific circumstances.
I use it as a temporary “checkpoint” or so. If I’m not sure if something ran as it should, I just have it print some gibberish or a random reference and see if it comes out. A better way to do it would probably be breakpoints, but I honestly don’t like having to press resume every time it gets called.
So um this was more of a rant than an actual question but I do still have some thoughts that I would like some community input on:
How do you use the print() method in a finished game? (or so, not sure how to word it to how I want)
I guess a little more in depth of the question is what would be good circumstances and reasonings to print something, and how should I give that information to the player (if at all)? There are probably many ways I could do it, but I haven’t used it purposefully other than in remnants of some old multiplayer code I inevitably dropped and some print_rich() errors for the save data code used from the Godot Docs.
I guess an example I could look at is Portal and Portal 2’s usage of it via hitting the tilda ~ quoteleft ` key which also allows for little command things. While I have no intention of adding vanilla cheats in any of my games (under very few exceptions), I would think that a popup for the output log thing could be useful for myself or specific players in late-development testing. Also I think Lethal Company has one where you press ctrl+H but I haven’t checked that one out much yet so I don’t have much thoughts on it

okay this is the end. I don’t have a good outro for this so I guess just insert the 5th grade approved “restate the thesis” or whatever thing here. cya

In minecraft you can hit f3 to get a bunch of debug info, maybe it could work like that?

It’s a good practice. I personally use print_rich() so I can color code my console output. Keep in mind that any console output just doesn’t happen in exported games unless you’ve exported a debug version. So it’s not a great reporting tool for normal users unless you give them a debug version.

If you want something players can use, there are logger Addons such as:

Ther’s also a new logger class you can exercise: How to use the new Logger class in Godot 4.5

I have no idea how useful they are on export without a debug version, but it’s something to look into.

3 Likes

Alright, so I will check out the links and figure out what I’m doing after the post-new-years exhaustion fades away tomorrow, but I do have a couple more questions (I’m sorry)

Really it’s just “what do I add” and “when should I start adding it”
(oh wait I’m not sure how I can elaborate on this um)

I did mention “loading map data,” “achievements,” “important kill count,” but that was more me trying to add descriptions so I wouldn’t be speaking complete gibberish. So yeah I still don’t know what to add in logs or debug info. Maybe there’s some games I could check out that do something that I could take inspiration off of? I am thinking about looking at the Portal series.

Also, when would be a good time to begin developing a log? Would it be good to start implementing print_rich()s in potentially necessary sections, maybe even to an overkill extent and just pluck out the poorly used ones? Or would it be better to create a Portal-like log (or Minceraft f3 menu as @paintsimmon mentions (I am actually quite interested in this concept)) sometime in late development and insert the logs necessary then?

((woa another long rant from this guy
also my first reply for some reason
I’m not sure why I’m adding this bit
I probably shouldn’t
oh well, cya))

Develop it as you go. That’s the best advice I can give. When you want the info, log it.

2 Likes

I recently started using a bool like debug_printing. Then instead of calling print(), calling a custom function debug_printing, which prints the message if debug printing == true.

It makes it easy to keep all the comments from when first making a script and trying to make it work and understand what is happening, without it clogging your terminal when you no longer need the prints. Then, if you would need tte prints again, just toggle it back on.

Maybe something similar could be useful for your idea? Some people may not want the prints and could turn them off, or some prints are not necessary for certain levels or game modes.

1 Like

As dragonforge-dev already said, you just need to add logs as you go, there isn’t really a correct answer.

However one bit of advice I can give; if something goes wrong in your game while developing, don’t immediately start checking the code to debug, see if you can figure out what went wrong just from the logs. If you can’t get a sense of what went wrong and why then you probably need to log some more things.

1 Like

This would be the benefit of using logging. You would then have access to logging levels, and could tweak it between OFF, INFO, WARN and ERROR.