Skip to content

Commit 007c60b

Browse files
nordic-krchgmarull
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit 60d8482)
1 parent ac76820 commit 007c60b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

subsys/logging/Kconfig.misc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ menu "Misc"
66
config LOG_CMDS
77
bool "Shell commands"
88
depends on SHELL
9-
depends on !LOG_FRONTEND_ONLY && !LOG_MODE_MINIMAL
9+
depends on !LOG_MODE_MINIMAL
1010

1111
config LOG_TEST_CLEAR_MESSAGE_SPACE
1212
bool "Clear message after allocation"

subsys/logging/log_cmds.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static const struct log_backend *backend_find(char const *name)
5858

5959
static bool shell_state_precheck(const struct shell *sh)
6060
{
61-
if (sh->log_backend->control_block->state
62-
== SHELL_LOG_BACKEND_UNINIT) {
61+
if (sh->log_backend &&
62+
(sh->log_backend->control_block->state == SHELL_LOG_BACKEND_UNINIT)) {
6363
shell_error(sh, "Shell log backend not initialized.");
6464
return false;
6565
}
@@ -142,8 +142,7 @@ static int cmd_log_self_status(const struct shell *sh,
142142
return 0;
143143
}
144144

145-
log_status(sh, sh->log_backend->backend, argc, argv);
146-
return 0;
145+
return log_status(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
147146
}
148147

149148
static int cmd_log_backend_status(const struct shell *sh,
@@ -246,7 +245,7 @@ static int cmd_log_self_enable(const struct shell *sh,
246245
return 0;
247246
}
248247

249-
return log_enable(sh, sh->log_backend->backend, argc, argv);
248+
return log_enable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
250249
}
251250

252251
static int cmd_log_backend_enable(const struct shell *sh,
@@ -271,7 +270,7 @@ static int cmd_log_self_disable(const struct shell *sh,
271270
return 0;
272271
}
273272

274-
return log_disable(sh, sh->log_backend->backend, argc, argv);
273+
return log_disable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
275274
}
276275

277276
static int cmd_log_backend_disable(const struct shell *sh,
@@ -327,7 +326,7 @@ static int cmd_log_self_halt(const struct shell *sh,
327326
return 0;
328327
}
329328

330-
return log_halt(sh, sh->log_backend->backend, argc, argv);
329+
return log_halt(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
331330
}
332331

333332
static int cmd_log_backend_halt(const struct shell *sh,
@@ -359,7 +358,7 @@ static int cmd_log_self_go(const struct shell *sh,
359358
return 0;
360359
}
361360

362-
return log_go(sh, sh->log_backend->backend, argc, argv);
361+
return log_go(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv);
363362
}
364363

365364
static int cmd_log_backend_go(const struct shell *sh,

0 commit comments

Comments
 (0)