pw_log_string: Split out the handler facade
Splits up pw_log_string to formalize the implicit facade for the
string log handler. In addition, it sets up the module so that the
mhandler can be used independently from the pw_log_string backend
for pw_log. This is useful when mixing tokenized and string based
logging on some targets.
Change-Id: I447b684079754093fbad8e311ef7564e38c74f72
Requires: pigweed-internal:24000
Requires: pigweed-internal:24020
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/87340
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
diff --git a/pw_log_string/docs.rst b/pw_log_string/docs.rst
index 63d7fad..d8f4409 100644
--- a/pw_log_string/docs.rst
+++ b/pw_log_string/docs.rst
@@ -3,28 +3,34 @@
=============
pw_log_string
=============
-``pw_log_string`` is a partial backend for ``pw_log``. This backend defines a
-C API that the ``PW_LOG_*`` macros will call out to. ``pw_log_string`` does not
-implement the C API, leaving projects to provide their own implementation.
-See ``pw_log_basic`` for a similar ``pw_log`` backend that also provides an
-implementation.
+``pw_log_string`` is a partial backend for ``pw_log``. This backend fowards the
+``PW_LOG_*`` macros to the ``pw_log_string:handler`` facade which is backed by
+a C API. ``pw_log_string:handler`` does not implement the full C API, leaving
+projects to provide their own implementation of
+``pw_log_string_HandleMessageVaList``. See ``pw_log_basic`` for a similar
+``pw_log`` backend that also provides an implementation.
As this module passes the log message, file name, and module name as a string to
the handler function, it's relatively expensive and not well suited for
space-constrained devices. This module is oriented towards usage on a host
(e.g. a simulated device).
+Note that ``pw_log_string:handler`` may be used even when it's not used
+as the backend for ``pw_log`` via ``pw_log_string``. For example it can be
+useful to mix tokenized and string based logging in case you have a C ABI where
+tokenization can not be used on the other side.
+
---------------
Getting started
---------------
This module is extremely minimal to set up:
-1. Implement ``pw_log_string_HandleMessage()``
+1. Implement ``pw_log_string_HandleMessageVaList()``
2. Set ``pw_log_BACKEND`` to ``"$dir_pw_log_string"``
-3. Set ``pw_log_string_BACKEND`` to point to the source set that implements
- ``pw_log_string_HandleMessage()``
+3. Set ``pw_log_string_HANDLER_BACKEND`` to point to the source set that
+ implements ``pw_log_string_HandleMessageVaList()``
-What exactly ``pw_log_string_HandleMessage()`` should do is entirely up to the
-implementation. ``pw_log_basic``'s log handler is one example, but it's also
+What exactly ``pw_log_string_HandleMessageVaList()`` should do is entirely up to
+the implementation. ``pw_log_basic``'s log handler is one example, but it's also
possible to encode as protobuf and send over a TCP port, write to a file, or
blink an LED to log as morse code.