Skip to content

Commit

Permalink
Add --no-header option to clean output
Browse files Browse the repository at this point in the history
* Do not print empty line when header is disabled
* Do not print Vulcan header
* Also add "Print header" project setting (default On)
  (suggested by @kaissouDev)
* Add docs for the project setting
  (with suggestions by @Mickeon and @akien-mga)

Co-authored-by: Micky <[email protected]>
Co-authored-by: A Thousand Ships <[email protected]>
Co-authored-by: Rémi Verschelde <[email protected]>
  • Loading branch information
4 people committed Feb 15, 2024
1 parent 907db8e commit e25cfff
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ bool Engine::is_printing_error_messages() const {
return CoreGlobals::print_error_enabled;
}

void Engine::print_header(const String &p_string) const {
if (_print_header) {
print_line(p_string);
}
}

void Engine::add_singleton(const Singleton &p_singleton) {
ERR_FAIL_COND_MSG(singleton_ptrs.has(p_singleton.name), vformat("Can't register singleton '%s' because it already exists.", p_singleton.name));
singletons.push_back(p_singleton);
Expand Down
3 changes: 3 additions & 0 deletions core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class Engine {
bool project_manager_hint = false;
bool extension_reloading = false;

bool _print_header = true;

static Engine *singleton;

String write_movie_path;
Expand Down Expand Up @@ -123,6 +125,7 @@ class Engine {

void set_print_error_messages(bool p_enabled);
bool is_printing_error_messages() const;
void print_header(const String &p_string) const;

void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
Expand Down
1 change: 1 addition & 0 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/run/main_scene", PROPERTY_HINT_FILE, "*.tscn,*.scn,*.res"), "");
GLOBAL_DEF("application/run/disable_stdout", false);
GLOBAL_DEF("application/run/disable_stderr", false);
GLOBAL_DEF("application/run/print_header", true);
GLOBAL_DEF_RST("application/config/use_hidden_project_data_directory", true);
GLOBAL_DEF("application/config/use_custom_user_dir", false);
GLOBAL_DEF("application/config/custom_user_dir_name", "");
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@
This setting can be overridden using the [code]--max-fps &lt;fps&gt;[/code] command line argument (including with a value of [code]0[/code] for unlimited framerate).
[b]Note:[/b] This property is only read when the project starts. To change the rendering FPS cap at runtime, set [member Engine.max_fps] instead.
</member>
<member name="application/run/print_header" type="bool" setter="" getter="" default="true">
If [code]true[/code], the engine header is printed in the console on startup. This header describes the current version of the engine, as well as the renderer being used. This behavior can also be disabled on the command line with the [code]--no-header[/code] option.
</member>
<member name="audio/buses/channel_disable_threshold_db" type="float" setter="" getter="" default="-60.0">
Audio buses will disable automatically when sound goes below a given dB threshold for a given time. This saves CPU as effects assigned to that bus will no longer do any processing.
</member>
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ typedef void(GLAPIENTRY *DEBUGPROCARB)(GLenum source,
typedef void(GLAPIENTRY *DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);

void RasterizerGLES3::initialize() {
print_line(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name()));
Engine::get_singleton()->print_header(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name()));
}

void RasterizerGLES3::finalize() {
Expand Down
15 changes: 12 additions & 3 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ void Main::print_help(const char *p_binary) {
print_help_option("--version", "Display the version string.\n");
print_help_option("-v, --verbose", "Use verbose stdout mode.\n");
print_help_option("--quiet", "Quiet mode, silences stdout messages. Errors are still displayed.\n");
print_help_option("--no-header", "Do not print engine version and rendering method header on startup.\n");

print_help_title("Run options");
print_help_option("--, ++", "Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from `OS.get_cmdline_user_args()`.\n");
Expand Down Expand Up @@ -1013,6 +1014,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph

quiet_stdout = true;

} else if (I->get() == "--no-header") {
Engine::get_singleton()->_print_header = false;

} else if (I->get() == "--audio-driver") { // audio driver

if (I->next()) {
Expand Down Expand Up @@ -1833,6 +1837,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (bool(GLOBAL_GET("application/run/disable_stderr"))) {
CoreGlobals::print_error_enabled = false;
}
if (!bool(GLOBAL_GET("application/run/print_header"))) {
// --no-header option for project settings.
Engine::get_singleton()->_print_header = false;
}

if (quiet_stdout) {
CoreGlobals::print_line_enabled = false;
Expand Down Expand Up @@ -2449,7 +2457,7 @@ Error Main::setup2() {
set_current_thread_safe_for_nodes(true);

// Print engine name and version
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
Engine::get_singleton()->print_header(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));

#ifdef TOOLS_ENABLED
if (editor || project_manager || cmdline_tool) {
Expand Down Expand Up @@ -2742,8 +2750,6 @@ Error Main::setup2() {

AudioDriverManager::initialize(audio_driver_idx);

print_line(" "); // Add a blank line for readability.

// Right moment to create and initialize the audio server.
audio_server = memnew(AudioServer);
audio_server->init();
Expand All @@ -2763,6 +2769,9 @@ Error Main::setup2() {

OS::get_singleton()->benchmark_end_measure("Startup", "Servers");

// Add a blank line for readability.
Engine::get_singleton()->print_header("");

register_core_singletons();

/* Initialize the main window and boot screen */
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/rendering_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4983,7 +4983,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ
}

// Output our device version.
print_line(vformat("%s %s - %s - Using Device #%d: %s - %s", get_device_api_name(), get_device_api_version(), rendering_method, device_index, _get_device_vendor_name(device), device.name));
Engine::get_singleton()->print_header(vformat("%s %s - %s - Using Device #%d: %s - %s", get_device_api_name(), get_device_api_version(), rendering_method, device_index, _get_device_vendor_name(device), device.name));
}

// Pick the main queue family. It is worth noting we explicitly do not request the transfer bit, as apparently the specification defines
Expand Down

0 comments on commit e25cfff

Please sign in to comment.