Skip to content

Commit

Permalink
logging: Add v2 support to native_posix backend
Browse files Browse the repository at this point in the history
Add support for logging v2 to native_posix backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
  • Loading branch information
nordic-krch authored and nashif committed Apr 19, 2021
1 parent 7ce3f7a commit e767bf6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion subsys/logging/Kconfig.backends
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions subsys/logging/log_backend_native_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdio.h>
#include <stddef.h>
#include <logging/log_backend.h>
#include <logging/log_backend_std.h>
#include <logging/log_core.h>
#include <logging/log_msg.h>
#include <logging/log_output.h>
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e767bf6

Please sign in to comment.