summaryrefslogtreecommitdiffstats
path: root/core/io
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-12-15 14:40:09 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-12-15 16:40:52 +0100
commit341b9cf15a6df3dae1ba6218b8545feec41fa728 (patch)
treee85d90ba04ce1cf58748307971fe7aaeb4e93d6d /core/io
parent6ccc6b6e28a49a40d6e31e66fc1ef258141c3f1d (diff)
downloadredot-engine-341b9cf15a6df3dae1ba6218b8545feec41fa728.tar.gz
Add a project setting to enable stdout flushing in release builds
This can be used in server builds for journalctl compatibility.
Diffstat (limited to 'core/io')
-rw-r--r--core/io/logger.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index f5cea00f28..241c72d310 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -30,6 +30,7 @@
#include "logger.h"
+#include "core/config/project_settings.h"
#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
@@ -201,15 +202,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 || 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();
}
}
@@ -228,9 +228,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 (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);
+ }
}
}