From c0808e3f59d0bcb378339734ccbbfc3394273434 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Fri, 19 Nov 2021 07:59:23 +0100 Subject: [PATCH] logging: Minimal mode configuration cleanup Remove LOG_MINIMAL kconfig option which was confusing since LOG_MODE_MINIMAL existed. LOG_MINIMAL was used to force minimal mode but because of invalid dependencies it was leading to issues. Refactored code to use LOG_MODE_MINIMAL everywhere and renamed LOG_MINIMAL to LOG_DEFAULT_MINIMAL which has impact on defualt logging mode (which still can be later changed in conf file or in menuconfig). Signed-off-by: Krzysztof Chruscinski --- include/logging/log.h | 2 +- include/logging/log_core.h | 12 ++++++------ include/logging/log_ctrl.h | 2 +- kernel/include/kernel_arch_interface.h | 2 +- subsys/bluetooth/host/monitor.c | 4 ++-- subsys/logging/CMakeLists.txt | 2 +- subsys/logging/Kconfig | 4 ++-- subsys/logging/Kconfig.filtering | 2 +- subsys/logging/Kconfig.misc | 4 ++-- subsys/logging/Kconfig.mode | 5 ++--- subsys/logging/Kconfig.processing | 4 ++-- subsys/shell/Kconfig | 2 +- subsys/testsuite/Kconfig | 2 +- 13 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/logging/log.h b/include/logging/log.h index 77345e22d8c..b4dfde74dcb 100644 --- a/include/logging/log.h +++ b/include/logging/log.h @@ -289,7 +289,7 @@ static inline void log_printk(const char *fmt, va_list ap) char *z_log_strdup(const char *str); static inline char *log_strdup(const char *str) { - if (IS_ENABLED(CONFIG_LOG_MINIMAL) || IS_ENABLED(CONFIG_LOG2)) { + if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL) || IS_ENABLED(CONFIG_LOG2)) { return (char *)str; } diff --git a/include/logging/log_core.h b/include/logging/log_core.h index 4e2d67e998e..ad385181957 100644 --- a/include/logging/log_core.h +++ b/include/logging/log_core.h @@ -33,7 +33,7 @@ extern "C" { #define CONFIG_LOG_MAX_LEVEL 0U #endif -#if !defined(CONFIG_LOG) || defined(CONFIG_LOG_MINIMAL) +#if !defined(CONFIG_LOG) || defined(CONFIG_LOG_MODE_MINIMAL) #define CONFIG_LOG_DOMAIN_ID 0U #endif @@ -299,7 +299,7 @@ static inline char z_log_minimal_level_to_char(int level) if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \ break; \ } \ - if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ + if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \ Z_LOG_TO_PRINTK(_level, __VA_ARGS__); \ break; \ } \ @@ -353,7 +353,7 @@ static inline char z_log_minimal_level_to_char(int level) uint32_t filters = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? \ (_dsource)->filters : 0;\ \ - if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ + if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \ Z_LOG_TO_PRINTK(_level, "%s", _str); \ z_log_minimal_hexdump_print(_level, \ (const char *)_data, _len);\ @@ -471,7 +471,7 @@ enum log_strdup_action { }; #define Z_LOG_PRINTK(...) do { \ - if (IS_ENABLED(CONFIG_LOG_MINIMAL) || !IS_ENABLED(CONFIG_LOG2)) { \ + if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL) || !IS_ENABLED(CONFIG_LOG2)) { \ z_log_minimal_printk(__VA_ARGS__); \ break; \ } \ @@ -731,7 +731,7 @@ __syscall void z_log_hexdump_from_user(uint32_t src_level_val, if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \ break; \ } \ - if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ + if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \ Z_LOG_TO_VPRINTK(_level, _str, _valist); \ break; \ } \ @@ -778,7 +778,7 @@ static inline log_arg_t z_log_do_strdup(uint32_t msk, uint32_t idx, log_arg_t param, enum log_strdup_action action) { -#ifndef CONFIG_LOG_MINIMAL +#ifndef CONFIG_LOG_MODE_MINIMAL char *z_log_strdup(const char *str); if (msk & (1 << idx)) { diff --git a/include/logging/log_ctrl.h b/include/logging/log_ctrl.h index 706341069a7..4e769988ded 100644 --- a/include/logging/log_ctrl.h +++ b/include/logging/log_ctrl.h @@ -189,7 +189,7 @@ uint32_t log_get_strdup_pool_utilization(void); */ uint32_t log_get_strdup_longest_string(void); -#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MINIMAL) +#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL) #define LOG_CORE_INIT() log_core_init() #define LOG_INIT() log_init() #define LOG_PANIC() log_panic() diff --git a/kernel/include/kernel_arch_interface.h b/kernel/include/kernel_arch_interface.h index ce5f4780e2c..dbb5567da41 100644 --- a/kernel/include/kernel_arch_interface.h +++ b/kernel/include/kernel_arch_interface.h @@ -540,7 +540,7 @@ uintptr_t arch_page_info_get(void *addr, uintptr_t *location, * Early boot console output hook * * Definition of this function is optional. If implemented, any invocation - * of printk() (or logging calls with CONFIG_LOG_MINIMAL which are backed by + * of printk() (or logging calls with CONFIG_LOG_MODE_MINIMAL which are backed by * printk) will default to sending characters to this function. It is * useful for early boot debugging before main serial or console drivers * come up. diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index fb940c19d38..8327a6318c1 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -233,7 +233,7 @@ extern void __printk_hook_install(int (*fn)(int)); extern void __stdout_hook_install(int (*fn)(int)); #endif /* !CONFIG_UART_CONSOLE */ -#ifndef CONFIG_LOG_MINIMAL +#ifndef CONFIG_LOG_MODE_MINIMAL struct monitor_log_ctx { size_t total_len; char msg[MONITOR_MSG_MAX]; @@ -375,7 +375,7 @@ static const struct log_backend_api monitor_log_api = { }; LOG_BACKEND_DEFINE(bt_monitor, monitor_log_api, true); -#endif /* CONFIG_LOG_MINIMAL */ +#endif /* CONFIG_LOG_MODE_MINIMAL */ static int bt_monitor_init(const struct device *d) { diff --git a/subsys/logging/CMakeLists.txt b/subsys/logging/CMakeLists.txt index 0abeee6b011..550d4efc086 100644 --- a/subsys/logging/CMakeLists.txt +++ b/subsys/logging/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -if(NOT CONFIG_LOG_MINIMAL) +if(NOT CONFIG_LOG_MODE_MINIMAL) zephyr_sources_ifdef( CONFIG_LOG log_list.c diff --git a/subsys/logging/Kconfig b/subsys/logging/Kconfig index 7f63205d7fe..13bcc8009da 100644 --- a/subsys/logging/Kconfig +++ b/subsys/logging/Kconfig @@ -14,7 +14,7 @@ rsource "Kconfig.mode" rsource "Kconfig.filtering" -if !LOG_FRONTEND && !LOG_MINIMAL +if !LOG_FRONTEND && !LOG_MODE_MINIMAL rsource "Kconfig.formatting" @@ -22,7 +22,7 @@ rsource "Kconfig.processing" rsource "Kconfig.backends" -endif # !LOG_FRONTEND && !LOG_MINIMAL +endif # !LOG_FRONTEND && !LOG_MODE_MINIMAL rsource "Kconfig.misc" diff --git a/subsys/logging/Kconfig.filtering b/subsys/logging/Kconfig.filtering index 689bc486b10..f4d5a4ab878 100644 --- a/subsys/logging/Kconfig.filtering +++ b/subsys/logging/Kconfig.filtering @@ -5,7 +5,7 @@ menu "Logging levels filtering" config LOG_RUNTIME_FILTERING bool "Runtime filtering reconfiguration" - depends on !LOG_FRONTEND && !LOG_MINIMAL + depends on !LOG_FRONTEND && !LOG_MODE_MINIMAL help Allow runtime configuration of maximal, independent severity level for instance. diff --git a/subsys/logging/Kconfig.misc b/subsys/logging/Kconfig.misc index 4c97e6d6f16..804ef88a74a 100644 --- a/subsys/logging/Kconfig.misc +++ b/subsys/logging/Kconfig.misc @@ -5,7 +5,7 @@ menu "Misc" config LOG_DOMAIN_ID int "Domain ID" - depends on !LOG_MINIMAL + depends on !LOG_MODE_MINIMAL default 0 range 0 7 help @@ -14,7 +14,7 @@ config LOG_DOMAIN_ID config LOG_CMDS bool "Enable shell commands" depends on SHELL - depends on !LOG_FRONTEND && !LOG_MINIMAL + depends on !LOG_FRONTEND && !LOG_MODE_MINIMAL default y if SHELL config LOG_TEST_CLEAR_MESSAGE_SPACE diff --git a/subsys/logging/Kconfig.mode b/subsys/logging/Kconfig.mode index 405537049d9..6548b074197 100644 --- a/subsys/logging/Kconfig.mode +++ b/subsys/logging/Kconfig.mode @@ -3,6 +3,7 @@ choice LOG_MODE prompt "Mode" + default LOG_MODE_MINIMAL if LOG_DEFAULT_MINIMAL default LOG_MODE_DEFERRED config LOG_MODE_DEFERRED @@ -71,7 +72,5 @@ config LOG_IMMEDIATE default y if LOG_MODE_IMMEDIATE default y if LOG2_MODE_IMMEDIATE -config LOG_MINIMAL +config LOG_DEFAULT_MINIMAL bool - imply PRINTK - default y if LOG_MODE_MINIMAL diff --git a/subsys/logging/Kconfig.processing b/subsys/logging/Kconfig.processing index a233ae2b812..6ac41aebe42 100644 --- a/subsys/logging/Kconfig.processing +++ b/subsys/logging/Kconfig.processing @@ -3,7 +3,7 @@ menu "Processing" -if !LOG_MINIMAL +if !LOG_MODE_MINIMAL config LOG_PRINTK bool "Process printk messages" @@ -167,6 +167,6 @@ config LOG_SPEED If enabled, logging may take more code size to get faster logging. endif # LOG2 -endif # !LOG_MINIMAL +endif # !LOG_MODE_MINIMAL endmenu diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 30d0b0a23f2..2234192914f 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -224,7 +224,7 @@ config SHELL_CMD_ROOT config SHELL_LOG_BACKEND bool "Enable shell log backend" - depends on LOG && !LOG_MINIMAL + depends on LOG && !LOG_MODE_MINIMAL default y if LOG help When enabled, backend will use the shell for logging. diff --git a/subsys/testsuite/Kconfig b/subsys/testsuite/Kconfig index f2afb99f1a4..235e74060a5 100644 --- a/subsys/testsuite/Kconfig +++ b/subsys/testsuite/Kconfig @@ -79,7 +79,7 @@ config TEST_LOGGING_DEFAULTS bool "Enable test case logging defaults" depends on TEST select LOG - imply LOG_MINIMAL + select LOG_DEFAULT_MINIMAL default y help Option which implements default policy of enabling logging in