diff --git a/subsys/logging/CMakeLists.txt b/subsys/logging/CMakeLists.txt index 70e94be360c..728ba037921 100644 --- a/subsys/logging/CMakeLists.txt +++ b/subsys/logging/CMakeLists.txt @@ -9,6 +9,11 @@ if(NOT CONFIG_LOG_MODE_MINIMAL) log_output.c ) + zephyr_sources_ifdef( + CONFIG_LOG_OUTPUT + log_output.c + ) + # Determine if __auto_type is supported. If not then runtime approach must always # be used. # Supported by: diff --git a/subsys/logging/Kconfig b/subsys/logging/Kconfig index f9f455261ff..1355e2ef6e6 100644 --- a/subsys/logging/Kconfig +++ b/subsys/logging/Kconfig @@ -16,13 +16,17 @@ rsource "Kconfig.filtering" rsource "Kconfig.processing" -if !LOG_FRONTEND_ONLY && !LOG_MODE_MINIMAL +if !LOG_MODE_MINIMAL rsource "Kconfig.formatting" +if !LOG_FRONTEND_ONLY + rsource "Kconfig.backends" -endif # !LOG_FRONTEND_ONLY && !LOG_MODE_MINIMAL +endif # !LOG_FRONTEND_ONLY + +endif # !LOG_MODE_MINIMAL if LOG_FRONTEND diff --git a/subsys/logging/Kconfig.backends b/subsys/logging/Kconfig.backends index a851b959248..b84aa2cf1a0 100644 --- a/subsys/logging/Kconfig.backends +++ b/subsys/logging/Kconfig.backends @@ -7,6 +7,7 @@ config LOG_BACKEND_UART bool "UART backend" depends on UART_CONSOLE default y if !SHELL_BACKEND_SERIAL + select LOG_OUTPUT help When enabled backend is using UART to output logs. @@ -54,6 +55,7 @@ endif # LOG_BACKEND_UART config LOG_BACKEND_SWO bool "Serial Wire Output (SWO) backend" depends on HAS_SWO + select LOG_OUTPUT help When enabled, backend will use SWO for logging. @@ -85,6 +87,7 @@ config LOG_BACKEND_RTT depends on USE_SEGGER_RTT default y if !SHELL_BACKEND_RTT select SEGGER_RTT_CUSTOM_LOCKING + select LOG_OUTPUT help When enabled, backend will use RTT for logging. This backend works on a per message basis. Only a whole message (terminated with a carriage return: '\r') @@ -189,6 +192,7 @@ config LOG_BACKEND_SPINEL bool "OpenThread dedicated Spinel protocol backend" depends on !LOG_BACKEND_UART depends on NET_L2_OPENTHREAD + select LOG_OUTPUT help When enabled, backend will use OpenThread dedicated SPINEL protocol for logging. This protocol is byte oriented and wraps given messages into serial frames. @@ -213,6 +217,7 @@ config LOG_BACKEND_NATIVE_POSIX bool "Native backend" depends on ARCH_POSIX default y if !SERIAL + select LOG_OUTPUT help Enable backend in native_posix @@ -228,6 +233,7 @@ config LOG_BACKEND_XTENSA_SIM bool "Xtensa simulator backend" depends on SOC_XTENSA_SAMPLE_CONTROLLER || SOC_FAMILY_INTEL_ADSP default y if SOC_XTENSA_SAMPLE_CONTROLLER + select LOG_OUTPUT help Enable backend in xtensa simulator @@ -253,6 +259,7 @@ config LOG_BACKEND_NET bool "Networking backend" depends on NETWORKING && NET_UDP && !LOG_MODE_IMMEDIATE select NET_CONTEXT_NET_PKT_POOL + select LOG_OUTPUT help Send syslog messages to network server. See RFC 5424 (syslog protocol) and RFC 5426 (syslog over UDP) @@ -313,6 +320,7 @@ endif # LOG_BACKEND_NET config LOG_BACKEND_ADSP bool "Intel ADSP buffer backend" depends on SOC_FAMILY_INTEL_ADSP + select LOG_OUTPUT help Enable backend for the host trace protocol of the Intel ADSP family of audio processors @@ -328,6 +336,7 @@ endif # LOG_BACKEND_ADSP config LOG_BACKEND_CAVS_HDA bool "cAVS HDA backend" depends on SOC_FAMILY_INTEL_ADSP && DMA && DMA_CAVS_HDA + select LOG_OUTPUT help Provide a logging backend which writes to a buffer and periodically flushes to hardware using ringbuffer like @@ -363,6 +372,7 @@ endif # LOG_BACKEND_CAVS_HDA config LOG_BACKEND_FS bool "File system backend" depends on FILE_SYSTEM + select LOG_OUTPUT help When enabled, backend is using the configured file system to output logs. As the file system must be mounted for the logging to work, it must be diff --git a/subsys/logging/Kconfig.formatting b/subsys/logging/Kconfig.formatting index de8f8733dc6..43cb658a990 100644 --- a/subsys/logging/Kconfig.formatting +++ b/subsys/logging/Kconfig.formatting @@ -21,6 +21,12 @@ config LOG_FUNC_NAME_PREFIX_DBG endmenu +config LOG_OUTPUT + bool "Formatter helper" + help + Module which provides formatting of log messages to a human-readable + strings. + menuconfig LOG_MIPI_SYST_ENABLE bool "MIPI SyS-T format output" select MIPI_SYST_LIB diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index 3693ca7152c..b184e3c9d61 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -54,7 +54,8 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE), #endif static const log_format_func_t format_table[] = { - [LOG_OUTPUT_TEXT] = log_output_msg_process, + [LOG_OUTPUT_TEXT] = IS_ENABLED(CONFIG_LOG_OUTPUT) ? + log_output_msg_process : NULL, [LOG_OUTPUT_SYST] = IS_ENABLED(CONFIG_LOG_MIPI_SYST_ENABLE) ? log_output_msg_syst_process : NULL, [LOG_OUTPUT_DICT] = IS_ENABLED(CONFIG_LOG_DICTIONARY_SUPPORT) ? @@ -330,7 +331,9 @@ int log_set_timestamp_func(log_timestamp_get_t timestamp_getter, uint32_t freq) } timestamp_func = timestamp_getter; - log_output_timestamp_freq_set(freq); + if (IS_ENABLED(CONFIG_LOG_OUTPUT)) { + log_output_timestamp_freq_set(freq); + } return 0; } diff --git a/tests/subsys/logging/log_output/prj.conf b/tests/subsys/logging/log_output/prj.conf index 2bba192e203..4f33f04803a 100644 --- a/tests/subsys/logging/log_output/prj.conf +++ b/tests/subsys/logging/log_output/prj.conf @@ -2,4 +2,5 @@ CONFIG_MAIN_THREAD_PRIORITY=5 CONFIG_ZTEST=y CONFIG_TEST_LOGGING_DEFAULTS=n CONFIG_LOG=y +CONFIG_LOG_OUTPUT=y CONFIG_LOG_PRINTK=n diff --git a/tests/subsys/logging/log_syst/prj.conf b/tests/subsys/logging/log_syst/prj.conf index f2faeca3cd2..262af62f571 100644 --- a/tests/subsys/logging/log_syst/prj.conf +++ b/tests/subsys/logging/log_syst/prj.conf @@ -2,6 +2,7 @@ CONFIG_LOG=y CONFIG_ASSERT=n CONFIG_ZTEST=y CONFIG_LOG_BACKEND_MOCK=y +CONFIG_LOG_OUTPUT=y CONFIG_LOG_BACKEND_UART=n CONFIG_SOC_LOG_LEVEL_OFF=y CONFIG_ARCH_LOG_LEVEL_OFF=y