1# Copyright (c) 2021 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4menu "Processing"
5
6if !LOG_MINIMAL
7
8config LOG_PRINTK
9	bool "Process printk messages"
10	help
11	  LOG_PRINTK messages are formatted in place and logged unconditionally.
12
13config LOG_PRINTK_MAX_STRING_LENGTH
14	int "Maximum string length supported by LOG_PRINTK"
15	depends on LOG_PRINTK
16	depends on (!LOG_IMMEDIATE || USERSPACE)
17	default 128
18	help
19	  Array is allocated on the stack.
20
21if !LOG_IMMEDIATE
22
23config LOG_MODE_OVERFLOW
24	bool "Drop oldest message when full"
25	default y
26	help
27	  If enabled, then if there is no space to log a new message, the
28	  oldest one is dropped. If disabled, current message is dropped.
29
30config LOG_BLOCK_IN_THREAD
31	bool "Block in thread context on full"
32	depends on MULTITHREADING
33	help
34	  When enabled logger will block (if in the thread context) when
35	  internal logger buffer is full and new message cannot be allocated.
36
37config LOG_BLOCK_IN_THREAD_TIMEOUT_MS
38	int "Maximum time (in milliseconds) thread can be blocked"
39	default 1000
40	range -1 10000
41	depends on LOG_BLOCK_IN_THREAD
42	help
43	  If new buffer for a log message cannot be allocated in that time, log
44	  message is dropped. Forever blocking (-1) is possible however may lead
45	  to the logger deadlock if logging is enabled in threads used for
46	  logging (e.g. logger or shell thread).
47
48config LOG_PROCESS_TRIGGER_THRESHOLD
49	int "Number of buffered log messages before flushing"
50	default 10
51	depends on MULTITHREADING
52	help
53	  When number of buffered messages reaches the threshold thread is waken
54	  up. Log processing thread ID is provided during log initialization.
55	  Set 0 to disable the feature. If LOG_PROCESS_THREAD is enabled then
56	  this threshold is used by the internal thread.
57
58config LOG_PROCESS_THREAD
59	bool "Use internal thread for log processing"
60	depends on MULTITHREADING
61	default y
62	help
63	  When enabled thread is created by the logger subsystem. Thread is
64	  waken up periodically (see LOG_PROCESS_THREAD_SLEEP_MS) and whenever
65	  number of buffered messages exceeds the threshold (see
66	  LOG_PROCESS_TRIGGER_THR).
67
68if LOG_PROCESS_THREAD
69
70config LOG_PROCESS_THREAD_STARTUP_DELAY_MS
71	int "Set log processing thread startup delay"
72	default 0
73	help
74	  Log processing thread starts after requested delay given in
75	  milliseconds. When started, thread process any buffered messages.
76
77config LOG_PROCESS_THREAD_SLEEP_MS
78	int "Set internal log processing thread sleep period"
79	default 1000
80	help
81	  Log processing thread sleeps for requested period given in
82	  milliseconds. When waken up, thread process any buffered messages.
83
84config LOG_PROCESS_THREAD_STACK_SIZE
85	int "Stack size for the internal log processing thread"
86	default 4096 if (X86 && X86_64)
87	default 4096 if ARM64
88	default 4096 if (ARC && 64BIT)
89	default 4096 if SPARC
90	default 2048 if COVERAGE_GCOV
91	default 2048 if (RISCV && 64BIT)
92	default 2048 if LOG_BACKEND_FS
93	default 1152 if LOG_BACKEND_NET
94	default 1024 if NO_OPTIMIZATIONS
95	default 1024 if XTENSA
96	default 768
97	help
98	  Set the internal stack size for log processing thread.
99
100endif # LOG_PROCESS_THREAD
101
102config LOG_BUFFER_SIZE
103	int "Number of bytes dedicated for the logger internal buffer"
104	default 1024
105	range 128 65536
106	help
107	  Number of bytes dedicated for the logger internal buffer.
108
109endif # !LOG_IMMEDIATE
110
111if LOG_MODE_DEFERRED
112
113config LOG_DETECT_MISSED_STRDUP
114	bool "Detect missed handling of transient strings"
115	default y if !LOG_IMMEDIATE
116	help
117	  If enabled, logger will assert and log error message is it detects
118	  that string format specifier (%s) and string address which is not from
119	  read only memory section and not from pool used for string duplicates.
120	  String argument must be duplicated in that case using log_strdup().
121	  Detection is performed during log processing thus it does not impact
122	  logging timing.
123
124config LOG_STRDUP_MAX_STRING
125	int "Longest string that can be duplicated using log_strdup()"
126	range 1 8192
127	default 66 if BT
128	default 46 if NETWORKING
129	default 32
130	help
131	  Longer strings are truncated.
132
133config LOG_STRDUP_BUF_COUNT
134	int "Number of buffers in the pool used by log_strdup()"
135	default 8 if BT
136	default 4
137	help
138	  Number of calls to log_strdup() which can be pending before flushed
139	  to output. If "<log_strdup alloc failed>" message is seen in the log
140	  output, it means this value is too small and should be increased.
141	  Each entry takes CONFIG_LOG_STRDUP_MAX_STRING bytes of memory plus
142	  some additional fixed overhead.
143
144config LOG_STRDUP_POOL_PROFILING
145	bool "Enable profiling of pool used for log_strdup()"
146	help
147	  When enabled, maximal utilization of the pool is tracked. It can
148	  be read out using shell command.
149
150endif # LOG_MODE_DEFERRED
151
152if LOG2
153
154config LOG_TRACE_SHORT_TIMESTAMP
155	bool "Use 24 bit timestamp for tracing"
156	default y
157	help
158	  When enabled, shorter timestamp is used and trace message is
159	  compressed.
160
161config LOG_TIMESTAMP_64BIT
162	bool "Use 64 bit timestamp"
163
164config LOG_SPEED
165	bool "Prefer performance over size"
166	help
167	  If enabled, logging may take more code size to get faster logging.
168endif # LOG2
169
170endif # !LOG_MINIMAL
171
172endmenu
173