blob: d8f44091751766526274d5276538f271e7a1695c [file] [log] [blame]
Armando Montanez1d5da9b2022-01-05 16:43:56 -08001.. _module-pw_log_string:
2
3=============
4pw_log_string
5=============
Ewout van Bekkum5ddc01d2022-03-08 12:50:25 -08006``pw_log_string`` is a partial backend for ``pw_log``. This backend fowards the
7``PW_LOG_*`` macros to the ``pw_log_string:handler`` facade which is backed by
8a C API. ``pw_log_string:handler`` does not implement the full C API, leaving
9projects to provide their own implementation of
10``pw_log_string_HandleMessageVaList``. See ``pw_log_basic`` for a similar
11``pw_log`` backend that also provides an implementation.
Armando Montanez1d5da9b2022-01-05 16:43:56 -080012
13As this module passes the log message, file name, and module name as a string to
14the handler function, it's relatively expensive and not well suited for
15space-constrained devices. This module is oriented towards usage on a host
16(e.g. a simulated device).
17
Ewout van Bekkum5ddc01d2022-03-08 12:50:25 -080018Note that ``pw_log_string:handler`` may be used even when it's not used
19as the backend for ``pw_log`` via ``pw_log_string``. For example it can be
20useful to mix tokenized and string based logging in case you have a C ABI where
21tokenization can not be used on the other side.
22
Armando Montanez1d5da9b2022-01-05 16:43:56 -080023---------------
24Getting started
25---------------
26This module is extremely minimal to set up:
27
Ewout van Bekkum5ddc01d2022-03-08 12:50:25 -0800281. Implement ``pw_log_string_HandleMessageVaList()``
Armando Montanez1d5da9b2022-01-05 16:43:56 -0800292. Set ``pw_log_BACKEND`` to ``"$dir_pw_log_string"``
Ewout van Bekkum5ddc01d2022-03-08 12:50:25 -0800303. Set ``pw_log_string_HANDLER_BACKEND`` to point to the source set that
31 implements ``pw_log_string_HandleMessageVaList()``
Armando Montanez1d5da9b2022-01-05 16:43:56 -080032
Ewout van Bekkum5ddc01d2022-03-08 12:50:25 -080033What exactly ``pw_log_string_HandleMessageVaList()`` should do is entirely up to
34the implementation. ``pw_log_basic``'s log handler is one example, but it's also
Armando Montanez1d5da9b2022-01-05 16:43:56 -080035possible to encode as protobuf and send over a TCP port, write to a file, or
36blink an LED to log as morse code.