Godot version: 3.1
Issue description:
I do use logging a lot to track things in the game and investigate bugs. But I don't believe that I do that in an efficient way (or that there's such way at all for GDScript). I believe this is a very basic feature, but I've failed to find something related to that.
What I expect from logger
This is a class that allows and supports:
printf special characters, for example:%t would mean current time like 2012-01-30T10:20:30Z or whatever%n would mean name of the logger%t would mean name of thread this logger is triggered from##ifdef DEBUG
logger.info("some interesting stuff here")
##endif
Currently, I'm doing this with my own Logger class written in GDScript and handling all that levels. But even so, when I need to dig into an issue and set logging level to TRACE (i.e. I see LOTS of logs with every little detail happening in my game) I get irritating message:
output overflow, print less text
But, hell, I do need to print lots of text!
You can use the global scope methods push_error() and push_warning() to print messages that will appear in the Errors tab when running the project from the editor. These messages can also be double-clicked to reach the code that emitted them.
Formatting can be achieved using the % formatting operator or the .format() String method, as explained in GDScript format strings.
Related #22202
@Calinou still, we lack more detailed levels like INFO, DEBUG and TRACE. What if I want to log some tracking stuff so that I can use that info later when investigating bugs? I don't think that's a good idea to log everything with push_error() / push_warning(). So my proposal is still valid.
P. S. Thanks for those methods, I didn't know that=)
EDIT:
Formatting with .format() is not what I meant. The point is to set up "log template string" (like "%time %name %message") once and then use only logger.debug(message) method. I do not want to provide time, logger name, etc each time I need to log a message
+1. I'm using a fork of this:
https://github.com/hedin-hiervard/godot-logger
I quite like Qt's way of doing it:
https://doc.qt.io/qt-5/qloggingcategory.html
There you can also use a conf file (INI) to enable/disable warnings.
@mitchcurtis thanks a lot, I'll take a look at that
+1. We also currently use the above mentioned godot-logger but it is quite limited currently. Also I think this is an important basic functionality which should be provided out of the box. An integrated logging mechanism also would make it possible to dynamically change the loglevel or logging scope in the editor during runtime and thus provide an additional benefit...
As this is a proposal and the related PR was closed - could this issue be moved to godotengine/godot-proposals in some way?
@pwab feel free to copy-paste it there, I don't mind :)
Since this was moved to proposals, it can be closed.
Most helpful comment
+1. We also currently use the above mentioned godot-logger but it is quite limited currently. Also I think this is an important basic functionality which should be provided out of the box. An integrated logging mechanism also would make it possible to dynamically change the loglevel or logging scope in the editor during runtime and thus provide an additional benefit...