mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-01 19:36:36 +00:00
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 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
2968b2c587
commit
c8ffe2a5e1
2 changed files with 19 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue