Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/releases/release-notes-4.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ New APIs and options

* Logging:

* Added options to skip timestamp and level in log backends.

* :kconfig:option:`CONFIG_LOG_BACKEND_SHOW_TIMESTAMP`
* :kconfig:option:`CONFIG_LOG_BACKEND_SHOW_LEVEL`

* Added rate-limited logging macros to prevent log flooding when messages are generated frequently.

* :c:macro:`LOG_ERR_RATELIMIT` - Rate-limited error logging macro (convenience)
Expand Down
5 changes: 5 additions & 0 deletions doc/services/logging/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ with function name. Hexdump messages are not prepended.
:kconfig:option:`CONFIG_LOG_FUNC_NAME_PREFIX_DBG`: Prepend standard DEBUG log messages
with function name. Hexdump messages are not prepended.

:kconfig:option:`CONFIG_LOG_BACKEND_SHOW_TIMESTAMP`: Enables backend to print timestamps
with log.

:kconfig:option:`CONFIG_LOG_BACKEND_SHOW_LEVEL`: Enables backend to print levels with log.

:kconfig:option:`CONFIG_LOG_BACKEND_SHOW_COLOR`: Enables coloring of errors (red)
and warnings (yellow).

Expand Down
10 changes: 9 additions & 1 deletion include/zephyr/logging/log_backend_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ extern "C" {

static inline uint32_t log_backend_std_get_flags(void)
{
uint32_t flags = (LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP);
uint32_t flags = 0;

if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_TIMESTAMP)) {
flags |= LOG_OUTPUT_FLAG_TIMESTAMP;
}

if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_LEVEL)) {
flags |= LOG_OUTPUT_FLAG_LEVEL;
}

if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
flags |= LOG_OUTPUT_FLAG_COLORS;
Expand Down
14 changes: 13 additions & 1 deletion subsys/logging/Kconfig.formatting
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ config LOG_IMMEDIATE_CLEAN_OUTPUT
this option is causing interrupts locking for significant amount of
time (up to multiple milliseconds).

config LOG_BACKEND_SHOW_TIMESTAMP
bool "Timestamps in the backend"
default y
help
When enabled, selected backend prints timestamps with log.

config LOG_BACKEND_SHOW_LEVEL
bool "Levels in the backend"
default y
help
When enabled, selected backend prints levels with log.

config LOG_BACKEND_SHOW_COLOR
bool "Colors in the backend"
default y if LOG_BACKEND_UART || LOG_BACKEND_NATIVE_POSIX || LOG_BACKEND_RTT \
Expand Down Expand Up @@ -172,7 +184,7 @@ config LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP
config LOG_BACKEND_FORMAT_TIMESTAMP
bool "Timestamp formatting in the backend"
depends on LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP
default y
default y if LOG_BACKEND_SHOW_TIMESTAMP
help
When enabled timestamp is formatted.

Expand Down