Skip to content

Commit e6d1941

Browse files
Nicholas Lowellnashif
authored andcommitted
shell / logging: shell log backend output Kconfig
Gives access to all log output format flag configurations for shell backend. shell log backend doesn't use log_backend_std_get_flags() and it's debateable if it should, so give it its own fullly configurable format set for maximum backend bandwidth control Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
1 parent 3c42773 commit e6d1941

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

subsys/shell/Kconfig

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,49 @@ config SHELL_LOG_BACKEND_CUSTOM
296296
It allows to provide custom implementation of multiplexing logging messages
297297
with shell data.
298298

299+
if SHELL_LOG_BACKEND
300+
301+
config SHELL_LOG_OUTPUT_TIMESTAMP
302+
bool "Log output timestamp"
303+
default y
304+
help
305+
Enable timestamp in log output.
306+
299307
config SHELL_LOG_FORMAT_TIMESTAMP
300308
bool "Format timestamp"
301309
default y
302-
depends on SHELL_LOG_BACKEND
303310
help
304311
Enable timestamp formatting.
305312

313+
config SHELL_LOG_OUTPUT_LEVEL
314+
bool "Log output level"
315+
default y
316+
help
317+
Enable log level in log output.
318+
319+
config SHELL_LOG_OUTPUT_CRLF_NONE
320+
bool "Log output CRLF none"
321+
help
322+
Do not modify CRLF characters in log output.
323+
324+
config SHELL_LOG_OUTPUT_CRLF_LFONLY
325+
bool "Log output CRLF LF only"
326+
help
327+
Convert CRLF to LF in log output.
328+
329+
config SHELL_LOG_OUTPUT_THREAD
330+
bool "Log output thread"
331+
default y
332+
help
333+
Enable logging thread id or name
334+
335+
config SHELL_LOG_OUTPUT_SKIP_SOURCE
336+
bool "Log output skip source"
337+
help
338+
Skip outputting source in log output.
339+
340+
endif # SHELL_LOG_BACKEND
341+
306342
config SHELL_AUTOSTART
307343
bool "Auto-start shell at boot"
308344
default y

subsys/shell/shell_log_backend.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,23 @@ static bool copy_to_pbuffer(struct mpsc_pbuf_buffer *mpsc_buffer,
155155
return true;
156156
}
157157

158+
/* Compile-time computed shell log output flags */
159+
#define SHELL_LOG_BASE_FLAGS \
160+
((IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_TIMESTAMP) ? LOG_OUTPUT_FLAG_TIMESTAMP : 0) | \
161+
(IS_ENABLED(CONFIG_SHELL_LOG_FORMAT_TIMESTAMP) ? LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP : 0) | \
162+
(IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_LEVEL) ? LOG_OUTPUT_FLAG_LEVEL : 0) | \
163+
(IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_CRLF_NONE) ? LOG_OUTPUT_FLAG_CRLF_NONE : 0) | \
164+
(IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_CRLF_LFONLY) ? LOG_OUTPUT_FLAG_CRLF_LFONLY : 0) | \
165+
(IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_THREAD) ? LOG_OUTPUT_FLAG_THREAD : 0) | \
166+
(IS_ENABLED(CONFIG_SHELL_LOG_OUTPUT_SKIP_SOURCE) ? LOG_OUTPUT_FLAG_SKIP_SOURCE : 0))
167+
158168
static void process_log_msg(const struct shell *sh,
159169
const struct log_output *log_output,
160170
union log_msg_generic *msg,
161171
bool locked, bool colors)
162172
{
163173
unsigned int key = 0;
164-
uint32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP | LOG_OUTPUT_FLAG_THREAD;
165-
166-
if (IS_ENABLED(CONFIG_SHELL_LOG_FORMAT_TIMESTAMP)) {
167-
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
168-
}
174+
uint32_t flags = SHELL_LOG_BASE_FLAGS;
169175

170176
if (colors) {
171177
flags |= LOG_OUTPUT_FLAG_COLORS;

0 commit comments

Comments
 (0)