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.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.2.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mflt_compact_log-0.0.2-py3-none-any.whl (40.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mflt_compact_log-0.0.2.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/6.2.0-33-generic

File hashes

Hashes for mflt_compact_log-0.0.2.tar.gz
Algorithm Hash digest
SHA256 29ad5d71b1bbce21ff9e393d7e37aa1ca45454fd231eec9c5889d05c133f7f9c
MD5 297d901b4ecc88ada62ebcf8c7c887c5
BLAKE2b-256 11cc3dce8031fdac064d9c455ab9f73238a6f13aa4e020a2a7448b875d652974

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mflt_compact_log-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 40.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/6.2.0-33-generic

File hashes

Hashes for mflt_compact_log-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7cbe409ab4f3d35bc46b104184eb3d57264760350371b84f166067548f9bc34b
MD5 cdee1e11dab0c26cacb7e1789dd38720
BLAKE2b-256 a49405a67222ad600a7e0bc0d2865f903e5f1e341780791b5a0f6c6917d322de

See more details on using hashes here.

Supported by

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