xref: /aosp_15_r20/external/pigweed/pw_log_basic/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_log_basic:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker------------
4*61c4878aSAndroid Build Coastguard Workerpw_log_basic
5*61c4878aSAndroid Build Coastguard Worker------------
6*61c4878aSAndroid Build Coastguard Worker``pw_log_basic`` is a ``pw_log`` backend that sends logs over ``pw_sys_io`` by
7*61c4878aSAndroid Build Coastguard Workerdefault. The destination of ``pw_sys_io`` depends on the ``pw_sys_io`` backend
8*61c4878aSAndroid Build Coastguard Workerin use. This is controlled by the ``dir_pw_sys_io_backend`` variable in a
9*61c4878aSAndroid Build Coastguard Workertarget's ``target_config.gni``.
10*61c4878aSAndroid Build Coastguard Worker
11*61c4878aSAndroid Build Coastguard WorkerThe log output may be changed from ``pw_sys_io`` to an arbitrary function by
12*61c4878aSAndroid Build Coastguard Workercalling ``pw::log_basic::SetOutput``.
13*61c4878aSAndroid Build Coastguard Worker
14*61c4878aSAndroid Build Coastguard Worker.. cpp:namespace:: pw::log_basic
15*61c4878aSAndroid Build Coastguard Worker
16*61c4878aSAndroid Build Coastguard Worker.. cpp:function:: void SetOutput(void (*log_output)(std::string_view))
17*61c4878aSAndroid Build Coastguard Worker
18*61c4878aSAndroid Build Coastguard Worker  Set the log output function, which defaults ``pw_sys_io::WriteLine``. This
19*61c4878aSAndroid Build Coastguard Worker  function is called with each formatted log message.
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard WorkerThis module employs an internal buffer for formatting log strings, whose size
22*61c4878aSAndroid Build Coastguard Workercan be configured via the ``PW_LOG_BASIC_ENTRY_SIZE`` macro which defaults to
23*61c4878aSAndroid Build Coastguard Worker150 bytes. Any final log statements that are larger than
24*61c4878aSAndroid Build Coastguard Worker``PW_LOG_BASIC_ENTRY_SIZE - 1`` bytes (one byte used for a null terminator) will
25*61c4878aSAndroid Build Coastguard Workerbe truncated.
26*61c4878aSAndroid Build Coastguard Worker
27*61c4878aSAndroid Build Coastguard Worker.. note::
28*61c4878aSAndroid Build Coastguard Worker  The documentation for this module is currently incomplete.
29