logging: Allow for compilation without log_output
Add option to Kconfig to enable log_output module. It is used
by most of the backends but it is an optional formatter helper
thus it is possible to run logging without it. One example might
be dictionary based logging which does not format log message
to a readable string.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
diff --git a/subsys/logging/CMakeLists.txt b/subsys/logging/CMakeLists.txt
index 70e94be..728ba03 100644
--- a/subsys/logging/CMakeLists.txt
+++ b/subsys/logging/CMakeLists.txt
@@ -9,6 +9,11 @@
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 f9f4552..1355e2e 100644
--- a/subsys/logging/Kconfig
+++ b/subsys/logging/Kconfig
@@ -16,13 +16,17 @@
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 a851b95..b84aa2c 100644
--- a/subsys/logging/Kconfig.backends
+++ b/subsys/logging/Kconfig.backends
@@ -7,6 +7,7 @@
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 @@
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 @@
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 @@
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 @@
bool "Native backend"
depends on ARCH_POSIX
default y if !SERIAL
+ select LOG_OUTPUT
help
Enable backend in native_posix
@@ -228,6 +233,7 @@
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 @@
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 @@
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 @@
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 @@
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 de8f873..43cb658 100644
--- a/subsys/logging/Kconfig.formatting
+++ b/subsys/logging/Kconfig.formatting
@@ -21,6 +21,12 @@
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 3693ca7..b184e3c 100644
--- a/subsys/logging/log_core.c
+++ b/subsys/logging/log_core.c
@@ -54,7 +54,8 @@
#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 @@
}
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 2bba192..4f33f04 100644
--- a/tests/subsys/logging/log_output/prj.conf
+++ b/tests/subsys/logging/log_output/prj.conf
@@ -2,4 +2,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 f2faeca..262af62 100644
--- a/tests/subsys/logging/log_syst/prj.conf
+++ b/tests/subsys/logging/log_syst/prj.conf
@@ -2,6 +2,7 @@
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