zephyr/samples/subsys/logging/logger
Andreas Sandberg 8ae5031aa5 samples: Add an SWO logger configuration fragment
The subsys/logging/logger example can be used to demonstrate how to
use SWO for logging. Add a configuration fragment that enables the
logger's SWO backend. The default SWO frequency in this example is set
to 2 MHz to ensure a well-defined output bit rate instead of the
highest possible.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
2023-12-12 10:56:44 +01:00
..
boards samples: logging: logger: Add configuration for nrf52840dk 2021-12-01 10:02:28 +01:00
src samples: subsys: logging: logger: remove nRF MDK-based code 2023-08-31 20:18:45 +02:00
arm_itm_swo.conf samples: Add an SWO logger configuration fragment 2023-12-12 10:56:44 +01:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Kconfig kconfig: Clean up header comments and make them consistent 2019-11-04 17:31:27 -05:00
prj.conf sample: logging: logger: Extend sample to use tag 2022-01-04 14:57:31 -06:00
README.rst doc: Migrate subsys/ code samples to new Sphinx extension 2023-09-21 09:28:31 +02:00
sample.yaml samples: logging: disable usermode for rtt platfroms 2023-12-07 21:11:01 +01:00
segger_uart_rtt.conf samples/doc: segger: rtt: enhanced tracing/logging 2023-08-06 07:44:06 -04:00
segger_uart_rtt.overlay samples/doc: segger: rtt: enhanced tracing/logging 2023-08-06 07:44:06 -04:00

.. zephyr:code-sample:: logging
   :name: Logging
   :relevant-api: log_api log_ctrl

   Output log messages to the console using the logging subsystem.

Overview
********
A simple application that demonstrates use of logging subsystem. It demonstrates
main features: severity levels, timestamping, module level filtering and
instance level filtering. It also showcases logging capabilities in terms of
performance.

Building and Running
********************

This project outputs multiple log message to the console.  It can be built and
executed on QEMU as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/logging/logger
   :host-os: unix
   :board: qemu_x86
   :goals: run
   :compact:


Sample Output
=============

.. code-block:: console

        Module logging showcase.
        [00:00:00.106,051] <inf> sample_module: log in test_module 11
        [00:00:00.106,054] <inf> sample_module: Inline function.
        Disabling logging in the sample_module module
        Function called again but with logging disabled.
        Instance level logging showcase.
        [00:00:00.106,200] <inf> sample_instance.inst1: Inline call.
        [00:00:00.106,204] <inf> sample_instance.inst1: counter_value: 0
        [00:00:00.106,209] <wrn> sample_instance.inst1: Example of hexdump:
        01 02 03 04             |....
        [00:00:00.106,214] <inf> sample_instance.inst2: Inline call.
        [00:00:00.106,218] <inf> sample_instance.inst2: counter_value: 0
        [00:00:00.106,223] <wrn> sample_instance.inst2: Example of hexdump:
        01 02 03 04             |....
        Changing filter to warning on sample_instance.inst1 instance.
        [00:00:00.106,297] <wrn> sample_instance.inst1: Example of hexdump:
        01 02 03 04             |....
        [00:00:00.106,302] <inf> sample_instance.inst2: Inline call.
        [00:00:00.106,307] <inf> sample_instance.inst2: counter_value: 1
        [00:00:00.106,311] <wrn> sample_instance.inst2: Example of hexdump:
        01 02 03 04             |....
        Disabling logging on both instances.
        Function call on both instances with logging disabled.
        String logging showcase.
        [00:00:01.122,316] <inf> main: Logging transient string:transient_string
        Severity levels showcase.
        [00:00:01.122,348] <err> main: Error message example.
        [00:00:01.122,352] <wrn> main: Warning message example.
        [00:00:01.122,355] <inf> main: Info message example.
        Logging performance showcase.
        [00:00:02.151,602] <inf> main: performance test - log message 0
        Estimated logging capabilities: 42000000 messages/second
        Logs from external logging system showcase.
        [00:00:03.165,977] <err> ext_log_system: critical level log
        [00:00:03.165,991] <err> ext_log_system: error level log, 1 arguments: 1
        [00:00:03.166,006] <wrn> ext_log_system: warning level log, 2 arguments: 12
        [00:00:03.166,025] <inf> ext_log_system: notice level log, 3 arguments: 105
        [00:00:03.166,044] <inf> ext_log_system: info level log, 4 arguments : 1 24

Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.