From 64ab22bf43f937443121b414ddd7997072fe555a Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Mon, 5 Sep 2022 07:16:21 +0200 Subject: [PATCH] shell: Add option to format logging timestamp Add option to control formatting of the logging timestamp. By default formatting is enabled which maintains backward compatibility. Signed-off-by: Krzysztof Chruscinski --- subsys/shell/Kconfig | 8 ++++++++ subsys/shell/shell_log_backend.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index ae3fbf41cf0..6187501dc73 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -238,6 +238,14 @@ config SHELL_LOG_BACKEND using the shell backend's LOG_LEVEL option (e.g. CONFIG_SHELL_TELNET_INIT_LOG_LEVEL_NONE=y). +config SHELL_LOG_FORMAT_TIMESTAMP + bool "Format timestamp" + default y + depends on SHELL_LOG_BACKEND + help + Enable timestamp formatting. + + source "subsys/shell/modules/Kconfig" endif # SHELL diff --git a/subsys/shell/shell_log_backend.c b/subsys/shell/shell_log_backend.c index e8dd83296f3..fae9315554f 100644 --- a/subsys/shell/shell_log_backend.c +++ b/subsys/shell/shell_log_backend.c @@ -158,7 +158,8 @@ static void process_log_msg(const struct shell *sh, unsigned int key = 0; uint32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP | - LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP; + (IS_ENABLED(CONFIG_SHELL_LOG_FORMAT_TIMESTAMP) ? + LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP : 0); if (colors) { flags |= LOG_OUTPUT_FLAG_COLORS;