-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add a way to access stdout and stderr's contents from the engine #536
Comments
I don't really get it, redirecting stderr and stdout is a feature your OS is supposed to have. |
The point is to redirect STDERR and STDOUT to the game itself, exposing an API for it, unless there's a different way to do this already. I think I may have worded it wrong, I want a way to access all engine logs at runtime, this includes whatever the engine prints. |
You can't do that by piping the STDERR/OUT of Godot's process. It could also be useful for multiple loggers working at the same time (writing to a file, to the console, etc at the same time), which would print everything, even the message from the engine itself. |
So you want a built-in Log singleton that wraps all of the print statements made by the engine and enables you to override/redirect/reprogram the logging behavior? I fully support that idea. Would be very useful. |
Yes, this is exactly what I mean. |
What would be the most logical singleton for exposing this? I'm thinking about |
Could add a boolean to enable monitoring of stderr and stdout (maybe a ProjectSettings option) and making get_stdout and get_stderr clean the buffer. |
Maybe versions of functions which print to stdout or stderr which return strings? |
@CRHough That requires modifying the code so you can get stdout/stderr, which is a no-go if you want to get output from C++ code (the engine itself) or add-ons you'd prefer not to modify. |
I'm new here and not sure if the proper way to do this is just to comment, but I'd like to second this proposal. I'm working on an adventure game engine built within Godot (an engine within an engine), which in the end would work entirely off of spreadsheets. You set up your characters.csv, scenes.csv, scripts.csv etc and run Godot, and it finds the files and plays the game. For developers there is a Debug Mode. All of my errors/logging goes to a log which can be viewed/filtered/etc while in this mode. However, certain error messages do not seem to be accessible from within Godot. For example, if you're editting a spreadsheet with Windows (even an Open Office one), it "helpfully" replaces dashes with emdashes and double quotes with whatever-they-are. This throws an error when converting get_csv_line (PoolStringArray) to a string: "Unicode error: invalid skip". I know what this error is, when it happens, and how to fix it. But if my engine-within-an-engine is going to work, then errors like these need to be caught somehow and routed to the debug log. Of course if there's another way to do this, feel free to enlighten me. :) Thanks! |
Note: I have discovered I was slightly off about which line threw the error (simply calling get_csv_line, which is expecting but not receiving UTF-8) and have solved this for myself by checking for a pool array result which consists of a single empty item. However, being able to access stdout would still be preferable, as there may be other miscellaneous errors which are sent to stdout rather than being thrown to Godot. (Alternately, in my own case, moving these errors to somewhere accessible by Godot - in the same way that's done with file reading, regex, etc - would also solve the problem). |
With the new extension system, exposing this to be made an extension is now possible, so IMO I think the proposal should be changed to exposing a way to make a custom logger. |
Closing, as this proposal needs to be rewritten to handle the creation of custom loggers instead (#536 (comment)). |
Describe the project you are working on:
A Rhythm Videogame
Describe the problem or limitation you are having in your project:
I would like to redirect standard outputs to my game so that I can log it myself and use it with steam logging services.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Some sort of mechanism to redirect stderr and stdout, this would not only include print() calls but anything the engine has printed too.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Could be a global singleton (or an existing one) that has a signal that is fired when a line is printed by the engine.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
You could continuously read the log files, but I am not sure how well that would work.
Is there a reason why this should be core and not an add-on in the asset library?:
It needs to be core because the only way you could solve it is with an engine module, and I am not entirely sure if it could even be done without changing the engine's code.
The text was updated successfully, but these errors were encountered: