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