xref: /aosp_15_r20/external/pigweed/pw_log_zephyr/Kconfig (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15menu "pw_log"
16
17choice PIGWEED_LOG
18    prompt "Logging backend used"
19    default PIGWEED_LOG_ZEPHYR if CPP
20    default PIGWEED_LOG_NONE
21    help
22      The type of Zephyr pw_log backend to use. See :ref:`module-pw_log` for
23      module details
24
25config PIGWEED_LOG_NONE
26    bool "Do not use Pigweed logging"
27    help
28      PW_LOG_ statements will not work.
29
30config PIGWEED_LOG_ZEPHYR
31    bool "Zephyr logging for PW_LOG_* statements"
32    select PIGWEED_PREPROCESSOR
33    help
34      Once the Pigweed logging is enabled, all Pigweed logs via PW_LOG_*() will
35      be routed to the Zephyr logging system. This means that:
36      - :c:macro:`PW_LOG_LEVEL_DEBUG` maps to Zephyr's LOG_LEVEL_DBG
37      - :c:macro:`PW_LOG_LEVEL_INFO` maps to Zephyr's LOG_LEVEL_INF
38      - :c:macro:`PW_LOG_LEVEL_WARN` maps to Zephyr's LOG_LEVEL_WRN
39      - :c:macro:`PW_LOG_LEVEL_ERROR` maps to Zephyr's LOG_LEVEL_ERR
40      - :c:macro:`PW_LOG_LEVEL_CRITICAL` maps to Zephyr's LOG_LEVEL_ERR
41      - :c:macro:`PW_LOG_LEVEL_FATAL` maps to Zephyr's LOG_LEVEL_ERR
42
43menuconfig PIGWEED_LOG_TOKENIZED
44    bool "Maps all Zephyr log macros to tokenized PW_LOG_* macros"
45    select PIGWEED_PREPROCESSOR
46    select PIGWEED_SYNC_INTERRUPT_SPIN_LOCK
47    select PIGWEED_SYS_IO
48    select PIGWEED_TOKENIZER
49    select LOG_CUSTOM_HEADER
50    select SHELL_CUSTOM_HEADER
51    help
52      Map all the Zephyr log macros to use Pigweed's then use the
53      :ref:`module-pw_log_tokenized` target as the logging backend in order to
54      automatically tokenize all the logging strings. This means that Pigweed
55      will also tokenize all of Zephyr's logging statements.
56
57config PIGWEED_LOG_TOKENIZED_LIB
58    bool "Tokenize logging and implement your own pw_log_tokenized_HandleLog"
59    select PIGWEED_TOKENIZER
60    select LOG_CUSTOM_HEADER
61    select SHELL_CUSTOM_HEADER
62    help
63      Same as PIGWEED_LOG_TOKENIZED but you'll need to implement
64      pw_log_tokenized_HandleLog. This gives you flexiblity to access handlers
65      outside of pigweed.
66
67config PIGWEED_LOG_NONE
68    bool "Do not use pigweed logging"
69    help
70      Pigweed log macros will not work unless the application manually
71      configures the logging backend.
72
73menuconfig PIGWEED_LOG_TOKENIZED_RPC
74    bool "Enables RPC tokenized logging"
75    select PIGWEED_SYNC_INTERRUPT_SPIN_LOCK
76    select PIGWEED_SYNC_THREAD_NOTIFICATION
77    select PIGWEED_SYNC_TIMED_THREAD_NOTIFICATION
78    select PIGWEED_SYSTEM_HDLC_RPC_SERVER
79    select PIGWEED_SYSTEM_LOG_BACKEND
80    select PIGWEED_SYSTEM_TARGET_HOOKS
81    select PIGWEED_THREAD
82    select PIGWEED_THREAD_ITERATION
83    select PIGWEED_TOKENIZER
84    select LOG_CUSTOM_HEADER
85    select SHELL_CUSTOM_HEADER
86    depends on CONSOLE_GETCHAR
87    help
88      Enable tokenized logging over RPC by using the system log backend.
89
90endchoice
91
92if PIGWEED_LOG_ZEPHYR || PIGWEED_LOG_TOKENIZED || PIGWEED_LOG_TOKENIZED_RPC
93
94choice "PIGWEED_LOG_LEVEL_CHOICE"
95	prompt "Max compiled-in log level for pigweed"
96	default PIGWEED_LOG_LEVEL_DEFAULT
97	depends on LOG
98
99config PIGWEED_LOG_LEVEL_OFF
100	bool "Off"
101	help
102	  Turn off all Pigweed logging.
103
104config PIGWEED_LOG_LEVEL_ERR
105	bool "Error"
106	help
107	  Only print error level log statements.
108
109config PIGWEED_LOG_LEVEL_WRN
110	bool "Warning"
111	help
112	  Only print warning level log statements and above.
113
114config PIGWEED_LOG_LEVEL_INF
115	bool "Info"
116	help
117	  Only print info level log statements and above.
118
119config PIGWEED_LOG_LEVEL_DBG
120	bool "Debug"
121	help
122	  Print all log statements.
123
124config PIGWEED_LOG_LEVEL_DEFAULT
125	bool "Default"
126	help
127	  Use Zephyr's ``LOG_DEFAULT_LEVEL`` as the log level.
128
129endchoice
130
131config PIGWEED_LOG_LEVEL
132	int
133	depends on LOG
134	default 0 if PIGWEED_LOG_LEVEL_OFF
135	default 1 if PIGWEED_LOG_LEVEL_ERR
136	default 2 if PIGWEED_LOG_LEVEL_WRN
137	default 3 if PIGWEED_LOG_LEVEL_INF
138	default 4 if PIGWEED_LOG_LEVEL_DBG
139	default LOG_DEFAULT_LEVEL if PIGWEED_LOG_LEVEL_DEFAULT
140
141endif # PIGWEED_LOG_ZEPHYR || PIGWEED_LOG_TOKENIZED || PIGWEED_LOG_TOKENIZED_RPC
142
143if PIGWEED_LOG_TOKENIZED
144rsource "Kconfig.tokenized"
145endif # PIGWEED_LOG_TOKENIZED
146
147endmenu
148