godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.99k stars 21.17k forks source link

Game process STDOUT is not captured and printed properly on Godot console #78114

Open rohanrhu opened 1 year ago

rohanrhu commented 1 year ago

Godot version

v4.0.3.stable.mono.official [5222a99f5]

System information

macOS 13.4 Ventura

Issue description

Hi,

When Godot 4 editor spawns the game process, the STDOUT of it is not captured and printed on editor console by Godot process.

We need this feature because we don't even have debugging support for threads and at least we could see error messages if we had this feature.

Steps to reproduce

This is a very important need when you do multi-threading...

For example:

Minimal reproduction project

Meow

AThousandShips commented 1 year ago

STDOUT from where? From raw C++ calls?

rohanrhu commented 1 year ago

STDOUT from where? From raw C++ calls?

Each process has a STDOUT, normally when Godot editors fork a new process, it has its own STDOUT, so it must be captured by the Godot editor process and print on editor console.

Things that are printed with GDScript's print() are captured by Godot's debug prtocol; because game process is connecting to debug server of the editor. But we must optionally on/off seeing STDOUT of game process too on the editor.

KoBeWi commented 1 year ago

Sounds like something that was fixed by #77080 Try in 4.1 beta

StagnationPoint commented 6 months ago

This is not fixed in 4.2.2. A simple test in a C#-enabled project is to put the following code somewhere it'll get hit:

System.Console.Out.WriteLine("foo");

I run the game in the editor, I do not see foo. Run it from the command line by invoking the editor with the --path argument supplied, and I do see it in the output.

Note that STDERR does not appear to be captured either. Ideally both would come through in the editor.

toolness commented 4 months ago

I found this confusing too, though I found the following workarounds.

This will log both Godot output and your thread's stdout/stderr to the console. It's not as ideal as seeing everything in the editor's actual console, but it's much better than nothing!

Note also that you may want to use the -e flag to ensure that your project is loaded in the editor, rather than just running the game itself, e.g. on Windows this might be:

cd <your project dir>
godot_console -e .