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

[3.x] Add print_verbose() built-in function to print in verbose mode only #53590

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Oct 9, 2021

3.x version of #52877. Unlike #52877, this also adds C# support for print_verbose().

This can be used as a shorthand for:

if OS.is_stdout_verbose():
    print("...")

Unlike print_debug(), this works in release builds too and can be toggled off in debug builds.

Preview

extends Node

func _ready():
	print("normal", " and ", "verbose")
	print_verbose("verbose", " only")

Verbose mode disabled

normal and verbose

Verbose mode enabled

Enable verbose stdout in the advanced project settings:

image

Alternatively, you can start Godot with the --verbose/-v command line argument.

normal and verbose
verbose only

@Calinou Calinou requested review from a team as code owners October 9, 2021 07:40
@Calinou Calinou added this to the 3.4 milestone Oct 9, 2021
@Calinou Calinou changed the title Add print_verbose() built-in function to print in verbose mode only Add print_verbose() built-in function to print in verbose mode only (3.x) Oct 9, 2021
@neikeq
Copy link
Contributor

neikeq commented Oct 9, 2021

I think it was said a few times that we should add proper logging, specially various logging levels. If that is really going to happen in the future then it might be better not to add this for now as it could break later (and it's easy to do as a custom function already). Ah, never mind. This is the 3.x version. The master one is already merged. Too late I guess.

@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@neikeq
Copy link
Contributor

neikeq commented Dec 1, 2021

I'm not a big fan of print_verbose because it always allocates. It can (and probably should) be replaced with a macro in C++ to avoid that, but for most language bindings it's unavoidable. C# and GDScript don't support lazy evaluation of arguments (neither does C++ tbh, but macro magic).

This can be used as a shorthand for:

    if OS.is_stdout_verbose():
        print("...")

Unlike `print_debug()`, this works in release builds too and can
be toggled off in debug builds.
@Calinou Calinou changed the title Add print_verbose() built-in function to print in verbose mode only (3.x) [3.x] Add print_verbose() built-in function to print in verbose mode only Jun 27, 2023
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.

4 participants