1.. _module-pw_log_basic: 2 3------------ 4pw_log_basic 5------------ 6.. pigweed-module:: 7 :name: pw_log_basic 8 9``pw_log_basic`` is a ``pw_log`` backend that sends logs over ``pw_sys_io`` by 10default. The destination of ``pw_sys_io`` depends on the ``pw_sys_io`` backend 11in use. This is controlled by the ``dir_pw_sys_io_backend`` variable in a 12target's ``target_config.gni``. 13 14Interface extension 15=================== 16The log output may be changed from ``pw_sys_io`` to an arbitrary function by 17calling ``pw::log_basic::SetOutput``. 18 19.. cpp:namespace:: pw::log_basic 20 21.. cpp:function:: void SetOutput(void (*log_output)(std::string_view)) 22 23 Set the log output function, which defaults ``pw_sys_io::WriteLine``. This 24 function is called with each formatted log message. 25 26Note that ``pw::log_baisc::SetOutput`` is not part of the :ref:`module-pw_log` 27interface. As a result, in the Bazel build, any build target that calls this 28function must: 29 30* Explicitly list ``@pigweed//pw_log_basic:extension`` in its ``deps``. This 31 avoids a :ref:`module-pw_toolchain-bazel-layering-check` violation. 32* Mark itself ``target_compatible_with`` only configurations for which the 33 `config_setting <https://bazel.build/reference/be/general#config_setting>`__ 34 ``@pigweed//pw_log_basic:is_active_backend`` is true. This informs the build 35 system that the target is only compatible with platforms that set the 36 :ref:`module-pw_log` backend to ``pw_log_basic``. 37 38See ``//pw_hdlc:hdlc_sys_io_system_server`` for an example of such a target. 39 40Implementation 41============== 42This module employs an internal buffer for formatting log strings, whose size 43can be configured via the ``PW_LOG_BASIC_ENTRY_SIZE`` macro which defaults to 44150 bytes. Any final log statements that are larger than 45``PW_LOG_BASIC_ENTRY_SIZE - 1`` bytes (one byte used for a null terminator) will 46be truncated. 47 48.. note:: 49 The documentation for this module is currently incomplete. 50