Skip to content

Commit f660c72

Browse files
committed
logging: Add v2 support to native_posix backend
Add support for logging v2 to native_posix backend. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 0a8b760 commit f660c72

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

subsys/logging/Kconfig.backends

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ endif # LOG_BACKEND_SPINEL
174174
config LOG_BACKEND_NATIVE_POSIX
175175
bool "Enable native backend"
176176
depends on ARCH_POSIX
177-
depends on !LOG2
178177
help
179178
Enable backend in native_posix
180179

subsys/logging/log_backend_native_posix.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdio.h>
99
#include <stddef.h>
1010
#include <logging/log_backend.h>
11+
#include <logging/log_backend_std.h>
1112
#include <logging/log_core.h>
1213
#include <logging/log_msg.h>
1314
#include <logging/log_output.h>
@@ -134,11 +135,20 @@ static void sync_hexdump(const struct log_backend *const backend,
134135
irq_unlock(key);
135136
}
136137

138+
static void process(const struct log_backend *const backend,
139+
union log_msg2_generic *msg)
140+
{
141+
uint32_t flags = log_backend_std_get_flags();
142+
143+
log_output_msg2_process(&log_output_posix, &msg->log, flags);
144+
}
145+
137146
const struct log_backend_api log_backend_native_posix_api = {
138-
.put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : put,
139-
.put_sync_string = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ?
147+
.process = IS_ENABLED(CONFIG_LOG2) ? process : NULL,
148+
.put = IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? put : NULL,
149+
.put_sync_string = IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE) ?
140150
sync_string : NULL,
141-
.put_sync_hexdump = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ?
151+
.put_sync_hexdump = IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE) ?
142152
sync_hexdump : NULL,
143153
.panic = panic,
144154
.dropped = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : dropped,

0 commit comments

Comments
 (0)