This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new c8ffe2a5e system/nxinit: add CONFIG_SYSTEM_NXINIT_STDOUT for
printf-based log output
c8ffe2a5e is described below
commit c8ffe2a5e110bbb834f20c64010403132ba7882a
Author: wangjianyu3 <[email protected]>
AuthorDate: Tue Mar 10 12:58:24 2026 +0800
system/nxinit: add CONFIG_SYSTEM_NXINIT_STDOUT for printf-based log output
Syslog may be output via services such as DFX. When debugging the init
component (e.g., service startup failures, including DFX-related
exceptions), syslog may not be output properly.
Add a debug Kconfig option SYSTEM_NXINIT_STDOUT that redirects all init
log macros (init_debug/info/warn/err) to printf instead of syslog.
This is useful for early boot debugging when syslog is not yet
available or serial console shows no output.
Introduce init_log_output() macro as the common log backend, selected
at compile time between printf (with appended newline) and syslog.
Signed-off-by: wangjianyu3 <[email protected]>
---
system/nxinit/Kconfig | 8 ++++++++
system/nxinit/init.h | 15 +++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/system/nxinit/Kconfig b/system/nxinit/Kconfig
index 9577c1d68..4b0d242bf 100644
--- a/system/nxinit/Kconfig
+++ b/system/nxinit/Kconfig
@@ -182,4 +182,12 @@ config SYSTEM_NXINIT_DEBUG
bool "Enable debug log"
depends on SYSTEM_NXINIT_INFO
+config SYSTEM_NXINIT_STDOUT
+ bool "Output log to stdout (printf)"
+ default n
+ ---help---
+ Debug option: redirect all init logs to stdout via printf
+ instead of syslog. Useful when syslog is not available or
+ serial console has no output during early boot.
+
endif
diff --git a/system/nxinit/init.h b/system/nxinit/init.h
index e6ce868fb..755363aea 100644
--- a/system/nxinit/init.h
+++ b/system/nxinit/init.h
@@ -28,6 +28,7 @@
****************************************************************************/
#include <poll.h>
+#include <stdio.h>
#include <syslog.h>
/****************************************************************************
@@ -36,8 +37,14 @@
#define TIMESPEC2MS(t) (((t).tv_sec * 1000) + (t).tv_nsec / 1000000)
+#ifdef CONFIG_SYSTEM_NXINIT_STDOUT
+#define init_log_output(level, fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#else
+#define init_log_output(level, ...) syslog(level, ##__VA_ARGS__)
+#endif
+
#ifdef CONFIG_SYSTEM_NXINIT_DEBUG
-#define init_debug(...) syslog(LOG_USER, ##__VA_ARGS__)
+#define init_debug(...) init_log_output(LOG_USER, ##__VA_ARGS__)
#define init_dump_args(argc, argv) \
{ \
int _i; \
@@ -52,19 +59,19 @@
#endif
#ifdef CONFIG_SYSTEM_NXINIT_INFO
-#define init_info(...) syslog(LOG_INFO, ##__VA_ARGS__)
+#define init_info(...) init_log_output(LOG_INFO, ##__VA_ARGS__)
#else
#define init_info(...)
#endif
#ifdef CONFIG_SYSTEM_NXINIT_WARN
-#define init_warn(...) syslog(LOG_WARNING, ##__VA_ARGS__)
+#define init_warn(...) init_log_output(LOG_WARNING, ##__VA_ARGS__)
#else
#define init_warn(...)
#endif
#ifdef CONFIG_SYSTEM_NXINIT_ERR
-#define init_err(f, ...) syslog(LOG_ERR, "Error " f, ##__VA_ARGS__)
+#define init_err(f, ...) init_log_output(LOG_ERR, "Error " f, ##__VA_ARGS__)
#else
#define init_err(...)
#endif