'How to get named list of arguments from fmt::format_args
I'm trying to build C++ logging integration for Logz.IO which uses named parameters for string interpolation and I'd like to leverage fmt for argument parsing and formatting. Essentially I'm trying to build function that will allow me to pass named arguments e.g.
log_fmt("Length: {Length:.2f}", fmt::arg("Length", 125.5f));
I followed documentation to build templated function and my own logging function:
template <typename S, typename... Args>
void log_fmt(const S& format, Args&&... args) {
vlog(level, format,
fmt::make_args_checked<Args...>(format, args...));
}
void vlog(fmt::string_view format, fmt::format_args args) {}
Inside my implementation of vlog I would like to convert args to JSON object that will contain all arguments (ideally without formatting part):
{
"Length": 125.5
}
However it looks like format_args exposes only very basic public interface (only allowing to get. How can I iterate over args and get each argument name and value?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
