README.rst
1.. zephyr:code-sample:: logging
2 :name: Logging
3 :relevant-api: log_api log_ctrl
4
5 Output log messages to the console using the logging subsystem.
6
7Overview
8********
9A simple application that demonstrates use of logging subsystem. It demonstrates
10main features: severity levels, timestamping, module level filtering and
11instance level filtering. It also showcases logging capabilities in terms of
12performance.
13
14Building and Running
15********************
16
17This project outputs multiple log message to the console. It can be built and
18executed on QEMU as follows:
19
20.. zephyr-app-commands::
21 :zephyr-app: samples/subsys/logging/logger
22 :host-os: unix
23 :board: qemu_x86
24 :goals: run
25 :compact:
26
27
28Sample Output
29=============
30
31.. code-block:: console
32
33 Module logging showcase.
34 [00:00:00.106,051] <inf> sample_module: log in test_module 11
35 [00:00:00.106,054] <inf> sample_module: Inline function.
36 Disabling logging in the sample_module module
37 Function called again but with logging disabled.
38 Instance level logging showcase.
39 [00:00:00.106,200] <inf> sample_instance.inst1: Inline call.
40 [00:00:00.106,204] <inf> sample_instance.inst1: counter_value: 0
41 [00:00:00.106,209] <wrn> sample_instance.inst1: Example of hexdump:
42 01 02 03 04 |....
43 [00:00:00.106,214] <inf> sample_instance.inst2: Inline call.
44 [00:00:00.106,218] <inf> sample_instance.inst2: counter_value: 0
45 [00:00:00.106,223] <wrn> sample_instance.inst2: Example of hexdump:
46 01 02 03 04 |....
47 Changing filter to warning on sample_instance.inst1 instance.
48 [00:00:00.106,297] <wrn> sample_instance.inst1: Example of hexdump:
49 01 02 03 04 |....
50 [00:00:00.106,302] <inf> sample_instance.inst2: Inline call.
51 [00:00:00.106,307] <inf> sample_instance.inst2: counter_value: 1
52 [00:00:00.106,311] <wrn> sample_instance.inst2: Example of hexdump:
53 01 02 03 04 |....
54 Disabling logging on both instances.
55 Function call on both instances with logging disabled.
56 String logging showcase.
57 [00:00:01.122,316] <inf> main: Logging transient string:transient_string
58 Severity levels showcase.
59 [00:00:01.122,348] <err> main: Error message example.
60 [00:00:01.122,352] <wrn> main: Warning message example.
61 [00:00:01.122,355] <inf> main: Info message example.
62 Logging performance showcase.
63 [00:00:02.151,602] <inf> main: performance test - log message 0
64 Estimated logging capabilities: 42000000 messages/second
65 Logs from external logging system showcase.
66 [00:00:03.165,977] <err> ext_log_system: critical level log
67 [00:00:03.165,991] <err> ext_log_system: error level log, 1 arguments: 1
68 [00:00:03.166,006] <wrn> ext_log_system: warning level log, 2 arguments: 12
69 [00:00:03.166,025] <inf> ext_log_system: notice level log, 3 arguments: 105
70 [00:00:03.166,044] <inf> ext_log_system: info level log, 4 arguments : 1 24
71
72Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
73