From 57da0404cfafb0cab880fa04bb9f90aa8939edd8 Mon Sep 17 00:00:00 2001 From: icex2 Date: Thu, 15 Aug 2024 11:34:31 +0200 Subject: [PATCH] fix: "Atomic" output log messages on minimial boot env, debug Fully format log messages and call OutputDebugStringA only once. This avoids getting split log messages on concurrent calls to OutputDebugStringA. --- src/main/core/boot.c | 14 ++++++-------- src/main/launcher/Module.mk | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/core/boot.c b/src/main/core/boot.c index 1c85d4c..283317c 100644 --- a/src/main/core/boot.c +++ b/src/main/core/boot.c @@ -12,9 +12,7 @@ #include "util/str.h" -#define CORE_BOOT_LOG_MODULE_SIZE_MAX 128 -/* 64k so we can log data dumps of rs232 without crashing */ -#define CORE_BOOT_LOG_MSG_SIZE_MAX 65536 +#define CORE_BOOT_LOG_MSG_SIZE_MAX 8192 static void _core_boot_log_std_msg(const char *module, const char *fmt, ...) { @@ -31,19 +29,19 @@ static void _core_boot_log_std_msg(const char *module, const char *fmt, ...) static void _core_boot_log_debug_msg(const char *module, const char *fmt, ...) { - char module_str[CORE_BOOT_LOG_MODULE_SIZE_MAX]; char msg[CORE_BOOT_LOG_MSG_SIZE_MAX]; + char msg2[CORE_BOOT_LOG_MSG_SIZE_MAX]; va_list args; va_start(args, fmt); - str_format(module_str, sizeof(module_str), "[%s] ", module); str_vformat(msg, sizeof(msg), fmt, args); - OutputDebugStringA(module_str); - OutputDebugStringA(msg); - OutputDebugStringA("\n"); va_end(args); + + str_format(msg2, sizeof(msg2), "[%s] %s\n", module, msg); + + OutputDebugStringA(msg2); } static void _core_boot_minimal_logging_std_env_init() diff --git a/src/main/launcher/Module.mk b/src/main/launcher/Module.mk index 5eceaca..432db2b 100644 --- a/src/main/launcher/Module.mk +++ b/src/main/launcher/Module.mk @@ -20,6 +20,7 @@ libs_launcher := \ iface \ module \ core \ + mxml \ src_launcher := \ app.c \