xref: /aosp_15_r20/external/pigweed/pw_assert_log/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1.. _module-pw_assert_log:
2
3=============
4pw_assert_log
5=============
6
7-----------------
8pw_assert_BACKEND
9-----------------
10This assert backend implements the ``pw_assert:check`` facade, by routing the
11``PW_CHECK()``/``PW_CRASH()`` macros into ``PW_LOG``  with the
12``PW_LOG_LEVEL_FATAL`` log level. This is an easy way to tokenize your assert
13messages, by using the ``pw_log_tokenized`` log backend for logging, then using
14``pw_assert_log`` to route the tokenized messages into the tokenized log
15handler.
16
17To use this module:
18
191. Set your assert backend: ``pw_assert_BACKEND = dir_pw_assert_log``
202. Ensure your logging backend knows how to handle the assert failure flag
21
22----------------------
23pw_assert_LITE_BACKEND
24----------------------
25This assert backend implements the ``pw_assert:assert`` facade, by routing the
26``PW_ASSERT()`` macros into ``PW_LOG`` with the ``PW_LOG_LEVEL_FATAL`` log
27level. This is an easy way to forward your asserts to a native macro assert
28API if it is already constexpr safe such as on Android.
29
30.. warning::
31   When building with Soong (using Android.bp), some Pigweed modules are listing
32   `pw_log_null_headers` in their `header_lib` list. This means that the
33   `PW_CHECK`, `PW_ASSERT`, and `PW_CRASH` macros that depend on logs are
34   ignored. Make sure to use the correct log backend in your final target, such
35   as the `pw_log_android` backend which supports crashing on
36   `PW_LOG_LEVEL_FATAL`. See
37   `b/324266698 <https://issues.pigweed.dev/324266698>`_.
38