Skip to content

Commit 9a3d762

Browse files
nordic-krchmmahadevan108
authored andcommitted
doc: logging: Update section about log processing
'Controlling the logging' section was not clear enough. Updating it to clarify that logging processing in deferred mode is by default handled implicitly. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 2f1c378 commit 9a3d762

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

doc/services/logging/index.rst

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,18 @@ level must be set using :c:macro:`LOG_LEVEL_SET`.
294294
Controlling the logging
295295
=======================
296296

297-
Logging can be controlled using API defined in
298-
:zephyr_file:`include/zephyr/logging/log_ctrl.h`. Logger must be initialized before it can be
299-
used. Optionally, user can provide function which returns timestamp value. If
300-
not provided, :c:macro:`k_cycle_get_32` is used for timestamping.
297+
By default, logging processing in deferred mode is handled internally by the
298+
dedicated task which starts automatically. However, it might not be available
299+
if multithreading is disabled. It can also be disabled by unsetting
300+
:kconfig:option:`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`. In that case, logging can
301+
be controlled using API defined in :zephyr_file:`include/zephyr/logging/log_ctrl.h`.
302+
Logging must be initialized before it can be used. Optionally, user can provide
303+
function which returns timestamp value. If not provided, :c:macro:`k_cycle_get`
304+
or :c:macro:`k_cycle_get_32` is used for timestamping.
301305
:c:func:`log_process` function is used to trigger processing of one log
302306
message (if pending). Function returns true if there is more messages pending.
307+
However, it is recommended to use macro wrappers (:c:macro:`LOG_INIT` and
308+
:c:macro:`LOG_PROCESS`) which handles case when logging is disabled.
303309

304310
Following snippet shows how logging can be processed in simple forever loop.
305311

@@ -309,20 +315,20 @@ Following snippet shows how logging can be processed in simple forever loop.
309315
310316
void main(void)
311317
{
312-
log_init();
318+
LOG_INIT();
319+
/* If multithreading is enabled provide thread id to the logging. */
320+
log_thread_set(k_current_get());
313321
314322
while (1) {
315-
if (log_process() == false) {
323+
if (LOG_PROCESS() == false) {
316324
/* sleep */
317325
}
318326
}
319327
}
320328
321-
If logs are processed from a thread then it is possible to enable a feature
322-
which will wake up processing thread when certain amount of log messages are
323-
buffered (see :kconfig:option:`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`). It is also
324-
possible to enable internal logging thread (see :kconfig:option:`CONFIG_LOG_PROCESS_THREAD`).
325-
In that case, logging thread is initialized and log messages are processed implicitly.
329+
If logs are processed from a thread (user or internal) then it is possible to enable
330+
a feature which will wake up processing thread when certain amount of log messages are
331+
buffered (see :kconfig:option:`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`).
326332

327333
.. _logging_panic:
328334

0 commit comments

Comments
 (0)