Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/zephyr/logging/log_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct log_backend_control_block {
void *ctx;
uint8_t id;
bool active;
bool initialized;

/* Initialization level. */
uint8_t level;
Expand Down Expand Up @@ -140,6 +141,7 @@ static inline void log_backend_init(const struct log_backend *const backend)
if (backend->api->init) {
backend->api->init(backend);
}
backend->cb->initialized = true;
}

/**
Expand Down
14 changes: 13 additions & 1 deletion subsys/logging/log_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,19 @@ static int log_go(const struct shell *sh,
char **argv)
{
if (backend || !IS_ENABLED(CONFIG_LOG_FRONTEND)) {
log_backend_activate(backend, backend->cb->ctx);
if (!backend->cb->initialized) {
log_backend_init(backend);
while (log_backend_is_ready(backend) != 0) {
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
k_msleep(10);
}
}
if (log_backend_is_ready(backend) == 0) {
log_backend_enable(backend, backend->cb->ctx, CONFIG_LOG_MAX_LEVEL);
}
} else {
log_backend_activate(backend, backend->cb->ctx);
}
return 0;
}

Expand Down
8 changes: 8 additions & 0 deletions subsys/logging/log_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ void log_core_init(void)
if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) {
z_log_runtime_filters_init();
}

STRUCT_SECTION_FOREACH(log_backend, backend) {
uint32_t id;
/* As first slot in filtering mask is reserved, backend ID has offset.*/
id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX;
id += backend - log_backend_get(0);
log_backend_id_set(backend, id);
}
}

static uint32_t activate_foreach_backend(uint32_t mask)
Expand Down
6 changes: 0 additions & 6 deletions subsys/logging/log_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,6 @@ void log_backend_enable(struct log_backend const *const backend,
void *ctx,
uint32_t level)
{
/* As first slot in filtering mask is reserved, backend ID has offset.*/
uint32_t id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX;

id += backend - log_backend_get(0);

log_backend_id_set(backend, id);
backend->cb->level = level;
backend_filter_set(backend, level);
log_backend_activate(backend, ctx);
Expand Down
Loading