Log dictionaries to MessagePack files in C++.
Add a git repository rule to your Bazel WORKSPACE
:
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/upkie/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.
The library is multi-threaded. Add messages to the log using the put
function, they will be written to file in the background.
#include <mpacklog/Logger.h>
#include <palimpsest/Dictionary.h>
int 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):
}
}
- mpacklog.py: Sibling Python project with an
mpacklog
command-line tool to manipulate MessagePack files. jq
: manipulate JSON series to add, remove or extend fields.rq
: transform from/to MessagePack, JSON, YAML, TOML, ...