shell: fix log output when CONFIG_LOG_IMMEDIATE=y
With CONFIG_LOG_IMMEDIATE, log output is printed immediately. If a shell command is in progress, there's no prompt to erase, nor should we print a new prompt after the log message is output. Before this patch, a simple shell command like: int cmd_log_erase(const struct shell *shell, size_t argc, char **argv) { LOG_INF("hello world"); return 0; } would output something like: uart:~$ log erase [00:00:02.623,718] <inf> cmd_log: hello world uart:~$ loguart:~$ This patch fixes prompt handling while a command is active, and fixes put_sync_hexdump to behave like put_sync_string. Signed-off-by: Jim Paris <jim@jtan.com>
This commit is contained in:
parent
942e9dcc90
commit
c7d6c310c6
1 changed files with 12 additions and 12 deletions
|
@ -222,10 +222,14 @@ static void put_sync_string(const struct log_backend *const backend,
|
||||||
}
|
}
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
shell_cmd_line_erase(shell);
|
if (!flag_cmd_ctx_get(shell)) {
|
||||||
|
shell_cmd_line_erase(shell);
|
||||||
|
}
|
||||||
log_output_string(shell->log_backend->log_output, src_level, timestamp,
|
log_output_string(shell->log_backend->log_output, src_level, timestamp,
|
||||||
fmt, ap, flags);
|
fmt, ap, flags);
|
||||||
shell_print_prompt_and_cmd(shell);
|
if (!flag_cmd_ctx_get(shell)) {
|
||||||
|
shell_print_prompt_and_cmd(shell);
|
||||||
|
}
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +238,6 @@ static void put_sync_hexdump(const struct log_backend *const backend,
|
||||||
const char *metadata, const u8_t *data, u32_t length)
|
const char *metadata, const u8_t *data, u32_t length)
|
||||||
{
|
{
|
||||||
const struct shell *shell = (const struct shell *)backend->cb->ctx;
|
const struct shell *shell = (const struct shell *)backend->cb->ctx;
|
||||||
struct k_poll_signal *signal;
|
|
||||||
u32_t key;
|
u32_t key;
|
||||||
u32_t flags = LOG_OUTPUT_FLAG_LEVEL |
|
u32_t flags = LOG_OUTPUT_FLAG_LEVEL |
|
||||||
LOG_OUTPUT_FLAG_TIMESTAMP |
|
LOG_OUTPUT_FLAG_TIMESTAMP |
|
||||||
|
@ -245,18 +248,15 @@ static void put_sync_hexdump(const struct log_backend *const backend,
|
||||||
}
|
}
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
shell_cmd_line_erase(shell);
|
if (!flag_cmd_ctx_get(shell)) {
|
||||||
|
shell_cmd_line_erase(shell);
|
||||||
|
}
|
||||||
log_output_hexdump(shell->log_backend->log_output, src_level, timestamp,
|
log_output_hexdump(shell->log_backend->log_output, src_level, timestamp,
|
||||||
metadata, data, length, flags);
|
metadata, data, length, flags);
|
||||||
irq_unlock(key);
|
if (!flag_cmd_ctx_get(shell)) {
|
||||||
|
shell_print_prompt_and_cmd(shell);
|
||||||
/* Even though log message is handled notify shell thread which
|
|
||||||
* will print command buffer after the log message.
|
|
||||||
*/
|
|
||||||
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
|
|
||||||
signal = &shell->ctx->signals[SHELL_SIGNAL_LOG_MSG];
|
|
||||||
k_poll_signal_raise(signal, 0);
|
|
||||||
}
|
}
|
||||||
|
irq_unlock(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void panic(const struct log_backend *const backend)
|
static void panic(const struct log_backend *const backend)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue