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 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.2.1] - 2026-01-20
- Add project description to
pyproject.toml
[0.2.0] - 2025-11-17
-
Remove support for Python < 3.10
-
Remove
clickdependency -
Add support for Truncated Compact Log entries
-
The command line tools,
mflt-compact-log.log_fmtandmflt-compact-log.decode_compact_log, have been moved into subcommands undermflt-compact-log:mflt-compact-log log-fmtmflt-compact-log decode
See
mflt-compact-log --helpfor details.
[0.1.1] - 2024-11-14
- Fix some missing dependencies that are required as of the
0.1.0release.
[0.1.0] - 2024-11-08
- Replace the wasmer-based decoder with a pure Python implementation
[0.0.5] - 2024-08-29
- Improve the output of
mflt-compact-log.log_fmtfor log format strings containing non-printable characters
[0.0.4] - 2024-06-13
- 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] - 2024-01-30
- 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
prettytabledependency from0.7.2to3.4.1 - update
pyelftoolsdependency from^0.28.0to^0.29.0
Metadata
Release files for mflt-compact-log 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mflt_compact_log-0.2.1.tar.gz | 15.3 kB | Without provenance | Details for mflt_compact_log-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mflt_compact_log-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for mflt_compact_log-0.2.1-py3-none-any.whl |
Total release size: 31.4 kB
Release files / mflt_compact_log-0.2.1.tar.gz
| Download URL | mflt_compact_log-0.2.1.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f81812f0a72ad3fbd68e52423addd58c56d030bb9b13b1aa3d4602e3f5fa73bc
|
|
BLAKE2b-256 checksum How to use checksums |
034c4c3839a3aaac74528a9f4ebf97696b1a2984b7844a6333622ea2982daa91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mflt_compact_log-0.2.1-py3-none-any.whl
| Download URL | mflt_compact_log-0.2.1-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37fc2e19373bdf320372afdca6a461fa3cf2d4d1fbb45d71bef9f7eea09fd7f6
|
|
BLAKE2b-256 checksum How to use checksums |
7ac101129d48b7e3c586e3ff0a971d454c05ddee4448ac58d085d0eca8261787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for mflt-compact-log 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.