From e767bf637781051d98e0acd852dac1cea314215e Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 26 Jan 2021 14:30:51 +0100 Subject: [PATCH] logging: Add v2 support to native_posix backend Add support for logging v2 to native_posix backend. Signed-off-by: Krzysztof Chruscinski --- subsys/logging/Kconfig.backends | 1 - subsys/logging/log_backend_native_posix.c | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/subsys/logging/Kconfig.backends b/subsys/logging/Kconfig.backends index 27f0f701908312..412cf935d8cc97 100644 --- a/subsys/logging/Kconfig.backends +++ b/subsys/logging/Kconfig.backends @@ -174,7 +174,6 @@ endif # LOG_BACKEND_SPINEL config LOG_BACKEND_NATIVE_POSIX bool "Enable native backend" depends on ARCH_POSIX - depends on !LOG2 help Enable backend in native_posix diff --git a/subsys/logging/log_backend_native_posix.c b/subsys/logging/log_backend_native_posix.c index a6d3f56e1177b6..18afcadf148b8d 100644 --- a/subsys/logging/log_backend_native_posix.c +++ b/subsys/logging/log_backend_native_posix.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -134,11 +135,20 @@ static void sync_hexdump(const struct log_backend *const backend, irq_unlock(key); } +static void process(const struct log_backend *const backend, + union log_msg2_generic *msg) +{ + uint32_t flags = log_backend_std_get_flags(); + + log_output_msg2_process(&log_output_posix, &msg->log, flags); +} + const struct log_backend_api log_backend_native_posix_api = { - .put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : put, - .put_sync_string = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? + .process = IS_ENABLED(CONFIG_LOG2) ? process : NULL, + .put = IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? put : NULL, + .put_sync_string = IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE) ? sync_string : NULL, - .put_sync_hexdump = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? + .put_sync_hexdump = IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE) ? sync_hexdump : NULL, .panic = panic, .dropped = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : dropped,