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

Add --no-header command line argument to silence the lines printed by Godot on startup #4998

Closed
abitrolly opened this issue Jul 28, 2022 · 14 comments · Fixed by godotengine/godot#79179
Milestone

Comments

@abitrolly
Copy link

abitrolly commented Jul 28, 2022

Describe the project you are working on

Command line script that uses Godot for visualization and stdout for piping results.

Describe the problem or limitation you are having in your project

stdout from script is always prepended with Godot version and debug info.

Godot Engine v3.4.4.stable.fedora.419e713a2 - https://godotengine.org
OpenGL ES 3.0 Renderer: Mesa Intel(R) HD Graphics 4400 (HSW GT2)
OpenGL ES Batching: ON

Using --quiet removes all stdout messages, including those from script,
and I'd to still read script messages.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allow to specify --quiet (or -q in 4.0) multiple times.

-q - silences godot messages, but leaves script output
-q -q - silences all stdout output

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Pseudo-code.

https://github.com/godotengine/godot/pull/63575/files

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not from within Godot.

Is there a reason why this should be core and not an add-on in the asset library?

Addons don't have control over internal Godot messages.

@Spartan322
Copy link

Spartan322 commented Jul 28, 2022

Wouldn't this technically count as a breaking change? Maybe not since I doubt anyone relies on it but this proposal's solution makes little sense to me, I agree in removing that with a commandline argument, but why is the solution double -q? I feel like double quiet arguments is pointless and would just lead to confusion, also I don't recall many applications that support doubling up on the same argument to distinctly modify behavior, why can't it be a separate argument?

@abitrolly
Copy link
Author

abitrolly commented Jul 28, 2022

godotengine/godot#55696 already changed -q behavior in 4.x to be a breaking change, although not --quiet.

Using verbosity options multiple times is used quite often for command line tools that have several levels of output.

The example from pip -h.

  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).

This one from python.

-v     : verbose (trace import statements); also PYTHONVERBOSE=x
         can be supplied multiple times to increase verbosity

There are probably others as well.

It is possible to add --no-header, but there can be other internal godot messages that are printed to stdout at some point.

@Spartan322
Copy link

godotengine/godot#55696 already changed -q behavior in 4.x to be a breaking change, although not --quiet.

Yeah, I was more so just pointing out its just changing the semantics of -q again, especially when I'd say its not warranted to use it for this purpose.

Using verbosity options multiple times is used quite often for command line tools that have several levels of output.

The example from pip -h.

  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).

But this has nothing to do with logging or verbosity because all it does is prevent the printing of the header to stdout, it doesn't affect anything regarding the logging levels. In that case my point stands.

This one from python.

-v     : verbose (trace import statements); also PYTHONVERBOSE=x
         can be supplied multiple times to increase verbosity

There are probably others as well.

To be fair I kind of hate python so this is likely why I never thought about it, but again verbosity is not the same thing here, the header doesn't apply to the logging, and this doesn't actually change that, in fact in the case you wanted to mimic that behavior this would violate that and then it would require breaking this functionality again. Better not to make that mistake inherently.

It is possible to add --no-header, but there can be other internal godot messages that are printed to stdout at some point.

Well yeah, this isn't supposed to be a solution to verbosity or logging, least your issue doesn't support that and neither does the associated PR, the point is to get rid of the header, why confuse that with logging or verbosity levels then? Its not like we're gonna specifically have a NO_HEADER verbosity/logging level for this, or at least I doubt that anyone would be okay with that.

@abitrolly abitrolly changed the title Suppress version header with -q and stdout with -q -q Suppress godot output, but not script output with -q or -qq Jul 28, 2022
@abitrolly abitrolly changed the title Suppress godot output, but not script output with -q or -qq Suppress godot output, but not script output with -q Jul 28, 2022
@abitrolly
Copy link
Author

the point is to get rid of the header

The point is to get rid of godot messages that are not related to the script output. It just happened that so far only the godot header was in the way. I updated the description to clarify this.

@Spartan322
Copy link

Spartan322 commented Jul 28, 2022

The point is to get rid of godot messages that are not related to the script output.

Well given that script output is a godot message, that doesn't technically make sense, I get what you're saying, but if error messages and warning messages are still gonna fire, literally all you're seeking is to remove the header in which case why describe it like that? This still doesn't change the verbosity. (which might be a useful feature but that isn't addressed here) Like if you're already running godot in no window mode and script mode, the only thing you'll be printing to the screen outside of whats in your script is the header, which is not associated with verbosity or logging anyway. (and I don't see where your use case presented falls outside of that bound) I just don't get why not target this specifically at the header, it kinda sounds like expanding of the scope of the problem beyond its bounds, not targeting the specific problem you're having, like maybe the maintainers disagree, I feel like you should keep this change local to what you specifically want without changing more then necessary. (nor changing the semantics of an existing functionality, least without what I feel is proper cause to do so, but again that's just me)

@abitrolly
Copy link
Author

Error messages are sent to stderr, so they won't affect script output. Not sure about warnings, but they are unwelcome on stdout too. The header is just one line.

Godot Engine v3.4.4.stable.fedora.419e713a2 - https://godotengine.org

I don't know yet where this one is coming from even if it looks like a header.

OpenGL ES 3.0 Renderer: Mesa Intel(R) HD Graphics 4400 (HSW GT2)
OpenGL ES Batching: ON

I'll be fine with --no-header for now, because I haven't encountered any
other messages from godot on stdout. Just adding yet another option
doesn't seem like a good solution to me, when it could be controlled by
existing options.

@Spartan322
Copy link

Spartan322 commented Jul 28, 2022

Error messages are sent to stderr

That's not guaranteed, most especially since you can disable printing to stderr at runtime, and it's neither guaranteed to be exclusive to stderr in Godot, and that's not much of a problem in other development applications because they support logging level command line arguments alongside that. But I just don't see how the goal of this is specifically to solve anything in regards to stdout, it doesn't feel like a valid place to apply -qq, (like that's a logging level style that I don't agree applies here) it just does not fit the commonality in other applications because all its doing is controlling the header, and its doing it with what is the common standard argument for silencing stdout. Adding an argument isn't a problem if its given proper justification, and least for me I can sympathize with removing the header from stdout as proper justification, specifically in regards to making scripts.

@ghost
Copy link

ghost commented Jun 21, 2023

I have a question, how to export a Godot game with --quiet flags ?

@Calinou
Copy link
Member

Calinou commented Jun 21, 2023

I have a question, how to export a Godot game with --quiet flags ?

Enable the Application > Run > Disable Stdout project setting, then export the project. Use the .release feature tag override to make this only affect projects exported in release mode, and not when running the project from the editor.

@ghost
Copy link

ghost commented Jun 21, 2023

OK, but if I do that, it will also delete the "print" in our gdscript code?

@Calinou
Copy link
Member

Calinou commented Jun 21, 2023

OK, but if I do that, it will also delete the "print" in our gdscript code?

Yes, as evidenced by the above replies in the proposal.

To remove only the header, you need to modify Godot's source code and recompile export templates for all platforms you wish to export to.

@ghost
Copy link

ghost commented Jun 22, 2023

but in :
editor/run/main_run_args
when I export my game, the argument doesn't apply, but it does in the editor

@Calinou
Copy link
Member

Calinou commented Jun 22, 2023

but in : editor/run/main_run_args when I export my game, the argument doesn't apply, but it does in the editor

The Disable Stdout project setting I mentioned does apply to the exported project. Main Run Args is intended to only affect the editor – it's not technically possible for it to affect an exported project.

@ghost
Copy link

ghost commented Jun 22, 2023

Ok, but here I was talking about other arguments and not necessarily --quiet, in any case thank you for the info.

@AThousandShips AThousandShips added this to the 4.x milestone Feb 11, 2024
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Feb 15, 2024
@Calinou Calinou changed the title Suppress godot output, but not script output with -q Add --no-header command line argument to silence the lines printed by Godot on startup Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants