Revert "Add a project setting to enable stdout flushing in release builds"

This reverts commit 341b9cf15a.

This makes the logger crash when used during cleanup: #44850.
This commit is contained in:
Rémi Verschelde 2021-01-05 13:32:41 +01:00
parent 58a1ed63bd
commit 66bfe855a8
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 9 additions and 24 deletions

View file

@ -33,7 +33,6 @@
#include "core/os/dir_access.h" #include "core/os/dir_access.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "core/print_string.h" #include "core/print_string.h"
#include "core/project_settings.h"
// va_copy was defined in the C99, but not in C++ standards before C++11. // va_copy was defined in the C99, but not in C++ standards before C++11.
// When you compile C++ without --std=c++<XX> option, compilers still define // When you compile C++ without --std=c++<XX> option, compilers still define
@ -205,14 +204,15 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) {
} }
va_end(list_copy); va_end(list_copy);
file->store_buffer((uint8_t *)buf, len); file->store_buffer((uint8_t *)buf, len);
if (len >= static_buf_size) { if (len >= static_buf_size) {
Memory::free_static(buf); Memory::free_static(buf);
} }
#ifdef DEBUG_ENABLED
if (p_err || GLOBAL_GET("application/run/flush_stdout_on_print")) { const bool need_flush = true;
// Don't always flush when printing stdout to avoid performance #else
// issues when `print()` is spammed in release builds. bool need_flush = p_err;
#endif
if (need_flush) {
file->flush(); file->flush();
} }
} }
@ -231,11 +231,9 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
vfprintf(stderr, p_format, p_list); vfprintf(stderr, p_format, p_list);
} else { } else {
vprintf(p_format, p_list); vprintf(p_format, p_list);
if (GLOBAL_GET("application/run/flush_stdout_on_print")) { #ifdef DEBUG_ENABLED
// Don't always flush when printing stdout to avoid performance fflush(stdout);
// issues when `print()` is spammed in release builds. #endif
fflush(stdout);
}
} }
} }

View file

@ -248,14 +248,6 @@
<member name="application/run/disable_stdout" type="bool" setter="" getter="" default="false"> <member name="application/run/disable_stdout" type="bool" setter="" getter="" default="false">
If [code]true[/code], disables printing to standard output in an exported build. If [code]true[/code], disables printing to standard output in an exported build.
</member> </member>
<member name="application/run/flush_stdout_on_print" type="bool" setter="" getter="" default="false">
If [code]true[/code], flushes the standard output stream every time a line is printed. This affects both terminal logging and file logging.
When running a project, this setting must be enabled if you want logs to be collected by service managers such as systemd/journalctl. This setting is disabled by default on release builds, since flushing on every printed line will negatively affect performance if lots of lines are printed in a rapid succession. Also, if this setting is enabled, logged files will still be written successfully if the application crashes or is otherwise killed by the user (without being closed "normally").
[b]Note:[/b] Regardless of this setting, the standard error stream ([code]stderr[/code]) is always flushed when a line is printed to it.
</member>
<member name="application/run/flush_stdout_on_print.debug" type="bool" setter="" getter="" default="true">
Debug build override for [member application/run/flush_stdout_on_print], as performance is less important during debugging.
</member>
<member name="application/run/frame_delay_msec" type="int" setter="" getter="" default="0"> <member name="application/run/frame_delay_msec" type="int" setter="" getter="" default="0">
Forces a delay between frames in the main loop (in milliseconds). This may be useful if you plan to disable vertical synchronization. Forces a delay between frames in the main loop (in milliseconds). This may be useful if you plan to disable vertical synchronization.
</member> </member>

View file

@ -369,11 +369,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
ClassDB::register_class<Performance>(); ClassDB::register_class<Performance>();
engine->add_singleton(Engine::Singleton("Performance", performance)); engine->add_singleton(Engine::Singleton("Performance", performance));
// Only flush stdout in debug builds by default, as spamming `print()` will
// decrease performance if this is enabled.
GLOBAL_DEF("application/run/flush_stdout_on_print", false);
GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true);
GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
MAIN_PRINT("Main: Parse CMDLine"); MAIN_PRINT("Main: Parse CMDLine");