Skip to main content

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:


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

>>> {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)
>>> 'An Integer Format String: 11'

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.1.tar.gz (41.4 kB view hashes)

Uploaded source

Built Distribution

mflt_compact_log-0.0.1-py3-none-any.whl (40.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page