Part 1
요약·해설
두 UART의 frontend filtering과 5개 exact binary/parser block을 보존합니다.
Binary log as hexadecimal
log_dictionary.json
log_parser.py --hex
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
F126D7D18D15536954F2E859C3B2A48315BF042B1870201579E57394D8B8A49F
.. zephyr:code-sample:: logging-dictionary
:name: Dictionary-based logging
:relevant-api: log_api
Output binary log data using the dictionary-based logging API.
Overview
********
This is a sample app which utilizes :ref:`dictionary-based logging <logging_guide_dictionary>` and
the UART backend. This is configured to output binary log data
in hexadecimal so it could be run in terminal.
There is also a configuration which shows how shell commands can be used to configure runtime
filtering of the logging messages for the frontend (in the same way as it is done for backends).
See ``log frontend`` set of commands and use ``log_rt_demo`` command to test the filtering.
Configuration with shell requires that board has two UART devices (one for the shell and one for
the UART dictionary based frontend).
Building and Running
********************
This application can be built and executed on QEMU as follows:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/logging/dictionary
:host-os: unix
:board: qemu_x86
:goals: run
:compact:
To build for another board, change "qemu_x86" above to that board's name.
Sample Output
=============
.. code-block:: none
SeaBIOS (version zephyr-v1.0.0-0-g31d4e0e-dirty-20200714_234759-fv-az50-zephyr)
Booting from ROM..##ZLOGV1##000004000000000000ecd7000004000000f76a10001e6b10001d6b1000000003000000000000b3e30000030000004d6410004464100000080200000000000093e70000020000005e64100000200300000000000076eb0000030000006b641000dc60100000180200000000000043ef0000020000007c64100000200500000000000066f300000500000088641000dc60100001000000020000000020050000000000008cf7000005000000a2641000dc6010001000000011000000002005000000000000b3fb000005000000be641000dc60100020000000210000000020070000000000000600010007000000da641000dc60100040000000000000004100000000000000002004000000000000491f0100040000000e651000dc60100021000000002004000000000000e02801000400000025651000dc6010001a651000006007000000000000993501000401000032651000dc601000000000000364796e616d6963207374720000201b0000000000000c5701000a04000043651000dc601000000000003f651000000000003f651000000000003f651000000000000364796e616d696320737472000564796e616d6963207374720007616e6f746865722064796e616d6963207374720009616e6f746865722064796e616d6963207374720000600b000000000000736a01000801000066651000dc601000210000001a651000000000001a651000210000000564796e616d696320737472000020040000000000008c6e01000400000083651000dc601000da0310000020041a0000000000967a010004000000ba651000dc601000ad65100048455844554d50212048455844554d50402048455844554d5023
Running the Log Parser
======================
1. Pipe the run output or copy the hexadecimal string into a temporary file ``/tmp/serial.log``:
.. code-block:: none
##ZLOGV1##000004000000000000ecd7000004000000f76a10001e6b10001d6b1000000003000000000000b3e30000030000004d6410004464100000080200000000000093e70000020000005e64100000200300000000000076eb0000030000006b641000dc60100000180200000000000043ef0000020000007c64100000200500000000000066f300000500000088641000dc60100001000000020000000020050000000000008cf7000005000000a2641000dc6010001000000011000000002005000000000000b3fb000005000000be641000dc60100020000000210000000020070000000000000600010007000000da641000dc60100040000000000000004100000000000000002004000000000000491f0100040000000e651000dc60100021000000002004000000000000e02801000400000025651000dc6010001a651000006007000000000000993501000401000032651000dc601000000000000364796e616d6963207374720000201b0000000000000c5701000a04000043651000dc601000000000003f651000000000003f651000000000003f651000000000000364796e616d696320737472000564796e616d6963207374720007616e6f746865722064796e616d6963207374720009616e6f746865722064796e616d6963207374720000600b000000000000736a01000801000066651000dc601000210000001a651000000000001a651000210000000564796e616d696320737472000020040000000000008c6e01000400000083651000dc601000da0310000020041a0000000000967a010004000000ba651000dc601000ad65100048455844554d50212048455844554d50402048455844554d5023
2. Run the log parser to get the text output:
.. code-block:: console
./scripts/logging/dictionary/log_parser.py build/zephyr/log_dictionary.json /tmp/serial.log --hex
And here is the output:
.. code-block:: none
*** Booting Zephyr OS build zephyr-v2.5.0-2471-g09b9eaf333e6 ***
Hello World! qemu_x86
[ 77820] <err> hello_world: error string
[ 86332] <dbg> hello_world: main: debug string
[ 96275] <inf> hello_world: info string
[ 104784] <dbg> hello_world: main: int8_t 1, uint8_t 2
[ 117609] <dbg> hello_world: main: int16_t 16, uint16_t 17
[ 130454] <dbg> hello_world: main: int32_t 32, uint32_t 33
[ 143299] <dbg> hello_world: main: int64_t 64, uint64_t 65
[ 166374] <dbg> hello_world: main: char !
[ 179452] <dbg> hello_world: main: s str static str
[ 193395] <dbg> hello_world: main: d str dynamic str
[ 217283] <dbg> hello_world: main: mixed str dynamic str --- dynamic str --- another dynamic str --- another dynamic str
[ 266022] <dbg> hello_world: main: mixed c/s ! static str dynamic str static str !
[ 287888] <dbg> hello_world: main: pointer 0x10651a
[ 301600] <dbg> hello_world: main: For HeXdUmP!
48 45 58 44 55 4d 50 21 20 48 45 58 44 55 4d 50 |HEXDUMP! HEXDUMP
40 20 48 45 58 44 55 4d 50 23 |@ HEXDUM P#
Part 3
한국어 전문 번역
개요
Dictionary-based logging과 UART backend를 사용하는 sample application입니다. Binary log data를 terminal에서 다룰 수 있도록 hexadecimal text로 출력합니다. Runtime에는 binary record를 build 때 생성한 dictionary와 결합해 원래 text log로 복원합니다.
별도 configuration은 shell command로 logging frontend의 runtime filtering을 설정하는 방법도 보여 줍니다. Backend filter와 같은 방식으로 log frontend command 집합을 사용하고, log_rt_demo로 filtering을 시험합니다.
Shell configuration에는 UART device가 두 개 필요합니다. 하나는 shell, 다른 하나는 UART dictionary-based frontend에 사용됩니다.
빌드 및 실행
다음 command로 qemu_x86에서 application을 build하고 실행합니다. 다른 board에서는 board 이름을 바꿉니다.
west build -b qemu_x86 samples/subsys/logging/dictionary
west build -t run
Sample 출력
UART에는 사람이 읽는 log 대신 ##ZLOGV1## header 뒤에 hexadecimal binary record가 이어집니다. 다음 block은 공식 sample output 전체입니다.
SeaBIOS (version zephyr-v1.0.0-0-g31d4e0e-dirty-20200714_234759-fv-az50-zephyr)
Booting from ROM..##ZLOGV1##000004000000000000ecd7000004000000f76a10001e6b10001d6b1000000003000000000000b3e30000030000004d6410004464100000080200000000000093e70000020000005e64100000200300000000000076eb0000030000006b641000dc60100000180200000000000043ef0000020000007c64100000200500000000000066f300000500000088641000dc60100001000000020000000020050000000000008cf7000005000000a2641000dc6010001000000011000000002005000000000000b3fb000005000000be641000dc60100020000000210000000020070000000000000600010007000000da641000dc60100040000000000000004100000000000000002004000000000000491f0100040000000e651000dc60100021000000002004000000000000e02801000400000025651000dc6010001a651000006007000000000000993501000401000032651000dc601000000000000364796e616d6963207374720000201b0000000000000c5701000a04000043651000dc601000000000003f651000000000003f651000000000003f651000000000000364796e616d696320737472000564796e616d6963207374720007616e6f746865722064796e616d6963207374720009616e6f746865722064796e616d6963207374720000600b000000000000736a01000801000066651000dc601000210000001a651000000000001a651000210000000564796e616d696320737472000020040000000000008c6e01000400000083651000dc601000da0310000020041a0000000000967a010004000000ba651000dc601000ad65100048455844554d50212048455844554d50402048455844554d5023
Log parser 실행
Run output을 pipe하거나 hexadecimal string을 임시 file /tmp/serial.log에 복사합니다.
##ZLOGV1##000004000000000000ecd7000004000000f76a10001e6b10001d6b1000000003000000000000b3e30000030000004d6410004464100000080200000000000093e70000020000005e64100000200300000000000076eb0000030000006b641000dc60100000180200000000000043ef0000020000007c64100000200500000000000066f300000500000088641000dc60100001000000020000000020050000000000008cf7000005000000a2641000dc6010001000000011000000002005000000000000b3fb000005000000be641000dc60100020000000210000000020070000000000000600010007000000da641000dc60100040000000000000004100000000000000002004000000000000491f0100040000000e651000dc60100021000000002004000000000000e02801000400000025651000dc6010001a651000006007000000000000993501000401000032651000dc601000000000000364796e616d6963207374720000201b0000000000000c5701000a04000043651000dc601000000000003f651000000000003f651000000000003f651000000000000364796e616d696320737472000564796e616d6963207374720007616e6f746865722064796e616d6963207374720009616e6f746865722064796e616d6963207374720000600b000000000000736a01000801000066651000dc601000210000001a651000000000001a651000210000000564796e616d696320737472000020040000000000008c6e01000400000083651000dc601000da0310000020041a0000000000967a010004000000ba651000dc601000ad65100048455844554d50212048455844554d50402048455844554d5023
Build가 만든 build/zephyr/log_dictionary.json, serial log, --hex option을 dictionary parser에 전달합니다.
./scripts/logging/dictionary/log_parser.py build/zephyr/log_dictionary.json /tmp/serial.log --hex
Parser는 binary record를 timestamp, severity, module, format string과 argument로 복원합니다. 결과에는 error·debug·info, 8/16/32/64-bit integer, character, static·dynamic·mixed string, pointer와 hexdump가 모두 나타납니다.
*** Booting Zephyr OS build zephyr-v2.5.0-2471-g09b9eaf333e6 ***
Hello World! qemu_x86
[ 77820] <err> hello_world: error string
[ 86332] <dbg> hello_world: main: debug string
[ 96275] <inf> hello_world: info string
[ 104784] <dbg> hello_world: main: int8_t 1, uint8_t 2
[ 117609] <dbg> hello_world: main: int16_t 16, uint16_t 17
[ 130454] <dbg> hello_world: main: int32_t 32, uint32_t 33
[ 143299] <dbg> hello_world: main: int64_t 64, uint64_t 65
[ 166374] <dbg> hello_world: main: char !
[ 179452] <dbg> hello_world: main: s str static str
[ 193395] <dbg> hello_world: main: d str dynamic str
[ 217283] <dbg> hello_world: main: mixed str dynamic str --- dynamic str --- another dynamic str --- another dynamic str
[ 266022] <dbg> hello_world: main: mixed c/s ! static str dynamic str static str !
[ 287888] <dbg> hello_world: main: pointer 0x10651a
[ 301600] <dbg> hello_world: main: For HeXdUmP!
48 45 58 44 55 4d 50 21 20 48 45 58 44 55 4d 50 |HEXDUMP! HEXDUMP
40 20 48 45 58 44 55 4d 50 23 |@ HEXDUM P#
마지막 hexdump는 byte를 hexadecimal과 ASCII 두 형태로 보여 줍니다. Timestamp와 pointer address는 공식 example run의 값이므로 실제 실행에서는 달라질 수 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.