Memfault Compact Log Library
Project description
Memfault Compact Log Library
This library enables decoding Memfault-flavored compact logs. For background information on compact logs, see here:
Usage
Some brief usage information below. See the source for detailed usage.
Extracting compact log format strings from .elf
To extract the format strings from the symbol file:
from mflt_compact_log.log_fmt import LogFormatElfSectionParser
elf = "path to elf file"
# parse the elf file
mappings = LogFormatElfSectionParser.get_mapping_from_elf_file(elf)
# 'mappings' is a dictionary mapping log id to LogFormatInfo data
print(mappings)
>>> {8: LogFormatInfo(filename='./main/console_example_main.c', line=245, n_args=0, fmt='This is a compact log example')}
Decoding compact logs
To apply the format string to raw compact log data:
from mflt_compact_log.compact import CompactLogDecoder
# example format string; this could instead be retrieved from the elf file
fmt = "An Integer Format String: %d"
# compact log hex encoded raw data
compact_log = "820A0B"
# decode the log!
compact_log_as_bytes = bytes.fromhex(compact_log)
log = CompactLogDecoder.from_cbor_array(fmt, compact_log_as_bytes)
log.decode()
>>> 'An Integer Format String: 11'
Changes
0.0.4
- Source pyelftools from https://pypi.org/project/pyelftools/ again, as the required bugfixes have been merged upstream. See notes of 0.0.3 below.
0.0.3
- Source pyelftools from https://github.com/memfault/pyelftools while we are waiting for 2 bugfixes to get merged upstream (https://github.com/eliben/pyelftools/pull/537 and https://github.com/eliben/pyelftools/pull/538).
0.0.2
- support Python 3.9 and 3.10
- update
prettytable
dependency from0.7.2
to3.4.1
- update
pyelftools
dependency from^0.28.0
to^0.29.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mflt_compact_log-0.0.4.tar.gz
(42.1 kB
view hashes)
Built Distribution
Close
Hashes for mflt_compact_log-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd8f92d0a4dcc03e2b1e4b7eb4b0051bcae7096774c3085c9ed811bbd910252e |
|
MD5 | 703bee7411320ca7458d35743976b447 |
|
BLAKE2b-256 | 51059d7db3138344213a48fb9cde161aebefa4f6dd050b23f4e6f8fbf4fd7667 |