You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-30 16:26:50 +00:00
Add a project setting to enable stdout flushing in release builds
This can be used in server builds for journalctl compatibility. (cherry picked from commit341b9cf15a) Fixes crash when exiting with --verbose with leaked resources (cherry picked from commit25c4dacb88)
This commit is contained in:
committed by
Rémi Verschelde
parent
ece69f8208
commit
15d9f77f97
@@ -33,6 +33,7 @@
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/os/os.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.
|
||||
// When you compile C++ without --std=c++<XX> option, compilers still define
|
||||
@@ -204,15 +205,14 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) {
|
||||
}
|
||||
va_end(list_copy);
|
||||
file->store_buffer((uint8_t *)buf, len);
|
||||
|
||||
if (len >= static_buf_size) {
|
||||
Memory::free_static(buf);
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
const bool need_flush = true;
|
||||
#else
|
||||
bool need_flush = p_err;
|
||||
#endif
|
||||
if (need_flush) {
|
||||
|
||||
if (p_err || !ProjectSettings::get_singleton() || GLOBAL_GET("application/run/flush_stdout_on_print")) {
|
||||
// Don't always flush when printing stdout to avoid performance
|
||||
// issues when `print()` is spammed in release builds.
|
||||
file->flush();
|
||||
}
|
||||
}
|
||||
@@ -231,9 +231,11 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
|
||||
vfprintf(stderr, p_format, p_list);
|
||||
} else {
|
||||
vprintf(p_format, p_list);
|
||||
#ifdef DEBUG_ENABLED
|
||||
fflush(stdout);
|
||||
#endif
|
||||
if (!ProjectSettings::get_singleton() || GLOBAL_GET("application/run/flush_stdout_on_print")) {
|
||||
// Don't always flush when printing stdout to avoid performance
|
||||
// issues when `print()` is spammed in release builds.
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user