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:

https://mflt.io/compact-logs

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.5] - 2024-08-29

  • improve the output of mflt-compact-log.log_fmt for log format strings containing non-printable characters

[0.0.4] - 2024-06-13

[0.0.3] - 2024-01-30

0.0.2

  • support Python 3.9 and 3.10
  • update prettytable dependency from 0.7.2 to 3.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.5.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

mflt_compact_log-0.0.5-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file mflt_compact_log-0.0.5.tar.gz.

File metadata

  • Download URL: mflt_compact_log-0.0.5.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.13 Linux/6.8.0-38-generic

File hashes

Hashes for mflt_compact_log-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2040470806a940503502d24e31ee90342a4da57b37e3c8a5efdd6680ce16640f
MD5 a5d5ab6fc8e41b3b3e082ccb700c4e35
BLAKE2b-256 c815af88b8f0c052083da07d18bc102d3367040b674954a5502fa6b74a72760e

See more details on using hashes here.

File details

Details for the file mflt_compact_log-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: mflt_compact_log-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.13 Linux/6.8.0-38-generic

File hashes

Hashes for mflt_compact_log-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 69197775f5e49d4be5edc0b9d02352007152802ac38cd6f7321ac3ec0497800d
MD5 d2f71693f0819b64088ec275cb74629f
BLAKE2b-256 b9798e15dca669cf87c7fba6df21cb1420c5f8531ab360eab058b7eb8820ab17

See more details on using hashes here.

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