Skip to content

Commit d98ec13

Browse files
Nicholas Lowellfabiobaltieri
authored andcommitted
logging: add all format options to Kconfig and std_get_flags()
Some but not all LOG_OUTPUT_ format flags were Kconfigurable for log backends using log_backend_std_get_flags() Adding the missing configurable flags to Kconfig and referencing them in log_backend_std_get_flags() for full control of output: - CRLF_NONE - CRLF_LFONLY - SKIP_SOURCE FORMAT_SYSLOG was omitted b/c it is specific to NET log backend. Signed-off-by: Nicholas Lowell <[email protected]>
1 parent d14a547 commit d98ec13

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

include/zephyr/logging/log_backend_std.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,22 @@ static inline uint32_t log_backend_std_get_flags(void)
4646
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
4747
}
4848

49+
if (IS_ENABLED(CONFIG_LOG_BACKEND_CRLF_NONE)) {
50+
flags |= LOG_OUTPUT_FLAG_CRLF_NONE;
51+
}
52+
53+
if (IS_ENABLED(CONFIG_LOG_BACKEND_CRLF_LFONLY)) {
54+
flags |= LOG_OUTPUT_FLAG_CRLF_LFONLY;
55+
}
56+
4957
if (IS_ENABLED(CONFIG_LOG_THREAD_ID_PREFIX)) {
5058
flags |= LOG_OUTPUT_FLAG_THREAD;
5159
}
5260

61+
if (IS_ENABLED(CONFIG_LOG_BACKEND_SKIP_SOURCE)) {
62+
flags |= LOG_OUTPUT_FLAG_SKIP_SOURCE;
63+
}
64+
5365
return flags;
5466
}
5567

subsys/logging/Kconfig.formatting

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,19 @@ config LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP
226226

227227
endchoice
228228

229+
config LOG_BACKEND_CRLF_NONE
230+
bool "Prevent adding CR and LF in logger"
231+
help
232+
When enabled, selected backend prints do not add CR and LF to log
233+
234+
config LOG_BACKEND_CRLF_LFONLY
235+
bool "Force a single LF for line breaks in logger"
236+
help
237+
When enabled, selected backend prints use single LF for line breaks in log
238+
239+
config LOG_BACKEND_SKIP_SOURCE
240+
bool "Skip logging the source"
241+
help
242+
When enabled, selected backend prints do not add the source to log
243+
229244
endmenu

0 commit comments

Comments
 (0)