logging: log_cmds: Enable log commands for shell with the logging frontend
When shell is integrated with the logging frontend then pointer to the logging backend in the shell structure is null. When null pointer is found assume that it is a shell instance with logging frontend integration and use frontend in the logging commands. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
6253c0678e
commit
60d8482348
2 changed files with 8 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ menu "Misc"
|
|||
config LOG_CMDS
|
||||
bool "Shell commands"
|
||||
depends on SHELL
|
||||
depends on !LOG_FRONTEND_ONLY && !LOG_MODE_MINIMAL
|
||||
depends on !LOG_MODE_MINIMAL
|
||||
|
||||
config LOG_TEST_CLEAR_MESSAGE_SPACE
|
||||
bool "Clear message after allocation"
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ static const struct log_backend *backend_find(char const *name)
|
|||
|
||||
static bool shell_state_precheck(const struct shell *sh)
|
||||
{
|
||||
if (sh->log_backend->control_block->state
|
||||
== SHELL_LOG_BACKEND_UNINIT) {
|
||||
if (sh->log_backend &&
|
||||
(sh->log_backend->control_block->state == SHELL_LOG_BACKEND_UNINIT)) {
|
||||
shell_error(sh, "Shell log backend not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -142,8 +142,7 @@ static int cmd_log_self_status(const struct shell *sh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
log_status(sh, sh->log_backend->backend, argc, argv);
|
||||
return 0;
|
||||
return log_status(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
|
||||
}
|
||||
|
||||
static int cmd_log_backend_status(const struct shell *sh,
|
||||
|
|
@ -246,7 +245,7 @@ static int cmd_log_self_enable(const struct shell *sh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return log_enable(sh, sh->log_backend->backend, argc, argv);
|
||||
return log_enable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
|
||||
}
|
||||
|
||||
static int cmd_log_backend_enable(const struct shell *sh,
|
||||
|
|
@ -271,7 +270,7 @@ static int cmd_log_self_disable(const struct shell *sh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return log_disable(sh, sh->log_backend->backend, argc, argv);
|
||||
return log_disable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
|
||||
}
|
||||
|
||||
static int cmd_log_backend_disable(const struct shell *sh,
|
||||
|
|
@ -327,7 +326,7 @@ static int cmd_log_self_halt(const struct shell *sh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return log_halt(sh, sh->log_backend->backend, argc, argv);
|
||||
return log_halt(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
|
||||
}
|
||||
|
||||
static int cmd_log_backend_halt(const struct shell *sh,
|
||||
|
|
@ -359,7 +358,7 @@ static int cmd_log_self_go(const struct shell *sh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return log_go(sh, sh->log_backend->backend, argc, argv);
|
||||
return log_go(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
|
||||
}
|
||||
|
||||
static int cmd_log_backend_go(const struct shell *sh,
|
||||
|
|
|
|||
Loading…
Reference in a new issue