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

Make -q to silence header, and stdout if specified twice #63575

Closed
wants to merge 4 commits into from

Conversation

abitrolly
Copy link
Contributor

@abitrolly abitrolly commented Jul 28, 2022

I am not sure it works, because quiet_header is defined in Main::setup and probably is not available in Main::setup2.

I'd like to silence the header, because I use some .gd scripts from command line, and need to pipe their output without extra lines from godot.

Bugsquad edit: This closes godotengine/godot-proposals#4998.

main/main.cpp Outdated Show resolved Hide resolved
@Calinou Calinou added this to the 4.0 milestone Jul 28, 2022
@Calinou
Copy link
Member

Calinou commented Jul 28, 2022

-qq should probably also be supported as an equivalent of -q -q.

@abitrolly abitrolly marked this pull request as ready for review July 28, 2022 16:41
@abitrolly abitrolly requested a review from a team as a code owner July 28, 2022 16:41
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fond of changing the meaning of -q and requiring specifying it twice to get back the proper quiet mode. I know some CLI works like this but that's bad design IMO (and usually it's for stuff like -v/-vv where it increases the verbosity, but here the -q behavior as of this PR does not make the output "quiet".

Instead I would add a --no-header parameter to silence the header independently from the rest.

@abitrolly
Copy link
Contributor Author

@akien-mga --no-header will only turn off this line.

Godot Engine v3.4.5.stable.fedora.f9ac000d5 - https://godotengine.org

But there are also these that are output in default mode.

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

Should they also depend on --no-header?

Can you tell what else would godot print in default mode? My use case is to make stdout completely clear from godot messages, but not from script messages to stdout. If --no-header is enough for that, I can redo PR for the new option.

@Calinou
Copy link
Member

Calinou commented Aug 30, 2022

Should they also depend on --no-header?

I think so, yes.

My use case is to make stdout completely clear from godot messages, but not from script messages to stdout. If --no-header is enough for that, I can redo PR for the new option.

Internal errors and warnings will still be printed by the engine with --no-header, but you can disable this by setting Engine.print_error_messages = false in a script. (This will also hide your own push_error()s and push_warning()s called in scripts.)

@abitrolly
Copy link
Contributor Author

Internal errors and warnings will still be printed by the engine

I hope they are printed to stderr, no?

@Calinou
Copy link
Member

Calinou commented Aug 30, 2022

I hope they are printed to stderr, no?

They should be if I'm not mistaken 🙂

@abitrolly
Copy link
Contributor Author

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

For these two lines I still need a pointer to filter them out.

@Calinou
Copy link
Member

Calinou commented Aug 30, 2022

For these two lines I still need a pointer to filter them out.

They should be filtered out with --no-header too, but you'll need to modify the engine so the "no header" status can be queried in other classes. This probably involves adding an engine setter/getter method + a property. (It doesn't have to be exposed to scripting, just used internally.)

@abitrolly
Copy link
Contributor Author

Seems doable. I still haven't found the class that outputs this info though.

@Calinou
Copy link
Member

Calinou commented Aug 30, 2022

Seems doable. I still haven't found the class that outputs this info though.

The lines printing the headers are:

master branch

3.x branch (not for this pull request, but if you intend to redo this for 3.x)

@ghost
Copy link

ghost commented Jul 6, 2023

But then you'll have to change the way "disable stdout" works or add a new parameter?

@Calinou
Copy link
Member

Calinou commented Jul 6, 2023

But then you'll have to change the way "disable stdout" works or add a new parameter?

Yes, a separate project setting should be added to toggle the header display (if you can get it to work, as the PCK that defines the project setting's value may be loaded after some of the headers are printed).

@abitrolly
Copy link
Contributor Author

I reworked this in #79179 to add --no-header option. Please take a look.

@ghost
Copy link

ghost commented Jul 8, 2023

I reworked this in #79179 to add --no-header option. Please take a look.

Good work !

@ghost
Copy link

ghost commented Jul 8, 2023

@abitrolly I opened a pull request based on tient to add --no-header to the project settings

@abitrolly
Copy link
Contributor Author

@kaissouDev nice! What is your story for exporting the game without console output? Are you making a roguelike for terminal in Godot? My use case for terminal is just have a script with a #!/usr/bin/env godot --no-header -q shebang and run it when needed for data processing and vis in a popup window.

@ghost
Copy link

ghost commented Jul 9, 2023

@kaissouDev nice! What is your story for exporting the game without console output? Are you making a roguelike for terminal in Godot? My use case for terminal is just have a script with a #!/usr/bin/env godot --no-header -q shebang and run it when needed for data processing and vis in a popup window.

Hello ! I just wanted to add the "--no-header" option to have more control over the console of our game without having 2 lines written automatically.

@abitrolly
Copy link
Contributor Author

abitrolly commented Jul 9, 2023

Maybe an option to customize that header would be a better fit for project options? The it can

  1. show the default engine info (advertise Godot engine)
  2. be set empty
  3. show customized engine info (and if the company sponsors Godot, link to that support page)

But I think that discussion belongs to a new issue at https://github.com/godotengine/godot-proposals

@ghost
Copy link

ghost commented Jul 9, 2023

Yes, that would be a good idea, I think it can be done if you store a variable and print it in the console, but then I don't really see the point because you can use gdscript for everything.

@abitrolly
Copy link
Contributor Author

abitrolly commented Jul 9, 2023

Yea, well, I guess I am just overthinking it. That header reminded me how Unity logo flashes on Kongregate games. Guess that's a feature of free Unity version. So I thought that if Godot has logo stripped, then how people would know that a game is made with Godot? Then I thought that maybe people who want to strip it are not limited in any way, and that's a good thing for them. But then there are people who want to help Godot and wouldn't mind advertising that they not only use Godot, but also support it.

EDIT: I needed to expand on the idea on how the header could be helpful for Godot.

@Calinou
Copy link
Member

Calinou commented Jul 9, 2023

I think that if you want to print a custom header, you should do it yourself in GDScript in an autoload's _ready() function. This allows using print_rich() and the like – something that a built-in implementation may not be able to do.

@ghost
Copy link

ghost commented Jul 9, 2023

you should do it yourself in GDScript in an autoload's _ready() function. This allows using print_rich()

but isn't print_rich for making texts in different colours?

@Calinou
Copy link
Member

Calinou commented Jul 9, 2023

but isn't print_rich for making texts in different colours?

Yes, and some people may want to use that in a header 🙂

In general, I'd avoid scope creep and just add an option to disable the built-in header. See Best practices for engine contributors.

@ghost
Copy link

ghost commented Jul 9, 2023

yes, I think it's preferable to use gdscript rather than integrate it directly into the editor, as that would take more time and be pointless

example:
image

@akien-mga
Copy link
Member

Superseded by #79179.

@akien-mga akien-mga closed this Feb 15, 2024
@AThousandShips AThousandShips removed this from the 4.x milestone Feb 15, 2024
@abitrolly abitrolly deleted the qq-no-head branch February 15, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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