pw_log_zephyr#
Pigweed AI summary: The pw_log_zephyr section provides an overview of the Pigweed logging backend implementation for Zephyr. It explains that there are two separate backends: one that uses the Zephyr logging framework and routes Pigweed's logs to Zephyr, and another that maps the Zephyr logging macros to Pigweed's tokenized logging. To enable Zephyr logging, the CONFIG_PIGWEED_LOG_ZEPHYR option needs to be set. All logs made through PW
Overview#
Pigweed AI summary: This paragraph provides an overview of the Pigweed interrupt backend that implements the "pw_log" facade. There are two separate backends implemented: one uses the Zephyr logging framework to route Pigweed's logs to Zephyr, while the other maps the Zephyr logging macros to Pigweed's tokenized logging. The paragraph also explains how to enable and control logging using Zephyr logging or Pigweed tokenized logging. It mentions additional configurations available for controlling metadata bits and modifying the log
This interrupt backend implements the pw_log
facade. Currently, two
separate Pigweed backends are implemented. One that uses the plain Zephyr
logging framework and routes Pigweed’s logs to Zephyr. While another maps
the Zephyr logging macros to Pigweed’s tokenized logging.
Using Zephyr logging#
Pigweed AI summary: This paragraph explains how to use Zephyr logging by enabling it with a specific configuration and controlling it through Kconfig options. All logs made through PW_LOG_* are logged to the Zephyr logging module pigweed, with Zephyr logging set as pw_log's backend.
To enable, set CONFIG_PIGWEED_LOG_ZEPHYR=y
. After that, logging can be
controlled via the standard Kconfig options. All logs made through
PW_LOG_* are logged to the Zephyr logging module pigweed
. In this
model, the Zephyr logging is set as pw_log
’s backend.
Using Pigweed tokenized logging#
Pigweed AI summary: The Pigweed tokenized logging feature can be enabled by setting CONFIG_PIGWEED_LOG_TOKENIZED=y. This allows the pw_log_tokenized to be used as the backend for pw_log, and all Zephyr logs are directed to Pigweed's logging facade. Enabling this feature also provides additional configurations to control the metadata bits for log level, line number, custom flags, and module string. The log format string can be customized by defining PW_LOG_TOKENIZED_FORMAT_STRING in the cmake file
Using the pigweed logging can be done by enabling
CONFIG_PIGWEED_LOG_TOKENIZED=y
. At that point pw_log_tokenized
is set
as the backend for pw_log
and all Zephyr logs are routed to Pigweed’s
logging facade. This means that any logging statements made in Zephyr itself
are also tokenized.
When enabled, a few extra configurations are available to control the tokenized
metadata bits such as log level bits, line number bits, custom flag bits, and
module string bits.
The log format string may also be modified by defining your own PW_LOG_TOKENIZED_FORMAT_STRING
.
This can be done in your cmake by including your own header that defines it.
add_library(log_tokenized_config INTERFACE)
target_compile_options(log_tokenized_config INTERFACE -include header_file_that_sets_that_macro.h)
pw_set_module_config(pw_log_tokenized_CONFIG log_tokenized_config)
Setting the log level#
Pigweed AI summary: This section discusses how the logging backend in Pigweed code respects the PW_LOG_LEVEL in order to translate Pigweed log levels to their closest Zephyr counterparts. It is also possible to set the Zephyr logging level directly via CONFIG_PIGWEED_LOG_LEVEL. A table is provided to show the mapping between Pigweed and Zephyr log levels.
In order to remain compatible with existing Pigweed code, the logging backend
respects PW_LOG_LEVEL
. If set, the backend will translate the Pigweed log
levels to their closest Zephyr counterparts:
Pigweed |
Zephyr |
---|---|
|
|
|
|
|
|
|
|
Alternatively, it is also possible to set the Zephyr logging level directly via
CONFIG_PIGWEED_LOG_LEVEL
.