https://github.com/stephane-caron/mpacklog.cpp
Log dictionaries to MessagePack files in C++
https://github.com/stephane-caron/mpacklog.cpp
cpp cpp17 cpp20 dictionary logging messagepack msgpack serialization
Last synced: about 1 month ago
JSON representation
Log dictionaries to MessagePack files in C++
- Host: GitHub
- URL: https://github.com/stephane-caron/mpacklog.cpp
- Owner: stephane-caron
- License: apache-2.0
- Created: 2023-09-27T10:13:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T13:21:08.000Z (about 2 months ago)
- Last Synced: 2025-04-10T14:24:07.321Z (about 2 months ago)
- Topics: cpp, cpp17, cpp20, dictionary, logging, messagepack, msgpack, serialization
- Language: Python
- Homepage:
- Size: 261 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mpacklog.cpp
[](https://github.com/stephane-caron/mpacklog.cpp/actions)
[](https://coveralls.io/github/stephane-caron/mpacklog.cpp?branch=main)
[](https://upkie.github.io/mpacklog.cpp/)

[](https://github.com/stephane-caron/mpacklog.cpp/releases)Log dictionaries to MessagePack files in C++.
## Installation
Add a git repository rule to your Bazel ``WORKSPACE``:
```python
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")http_archive(
name = "mpacklog",
sha256 = "389cbd249607f1d0a2bbf6d11cbf0690604966e29a8e75e50160cf0faab068c7",
strip_prefix = "mpacklog.cpp-3.1.0",
url = "https://github.com/stephane-caron/mpacklog.cpp/archive/refs/tags/v3.1.0.tar.gz",
)load("@mpacklog//tools/workspace:default.bzl", add_mpacklog_repositories = "add_default_repositories")
# This adds dependencies such as @palimpsest for building mpacklog targets
add_mpacklog_repositories()
```You can then use the ``@mpacklog`` dependency in your C++ targets.
## Usage
The library is multi-threaded. Add messages to the log using the [`put`](https://scaron.info/doc/mpacklog/classmpacklog_1_1Logger.html#af0c278a990b1275b306e89013bb1fac6) function, they will be written to file in the background.
```cpp
#include
#includeint main() {
mpacklog::Logger logger("output.mpack");for (unsigned bar = 0; bar < 1000u; ++bar) {
palimpsest::Dictionary dict;
dict("foo") = bar;
dict("something") = "else";
logger.put(dict):
}
}
```## See also
* [mpacklog.py](https://github.com/stephane-caron/mpacklog.py): Sibling Python project with an `mpacklog` command-line tool to manipulate MessagePack files.
* [`jq`](https://github.com/stedolan/jq): manipulate JSON series to add, remove or extend fields.
* [`rq`](https://github.com/dflemstr/rq): transform from/to MessagePack, JSON, YAML, TOML, ...