In my code I use printf-like LOG(const char* fmt, ...) macro. Under the hood it prints/logs to different output destinations (file, console, debugger output).
It's my own macro, so it does printf format when there are 2+ args, and logs strings as-is when only one argument is passed.
I want to update or extend it, so that it could take list args to log. So that it could work similar to console.log in javascript, except it would also log arg names. For example:
int64_t x = -1234;
unsigned volume = 10;
double pi = 3.1415926535;
const char* name = "test";
std::string str = "hello";
LOG(x, volume, pi, name, str);
should log something like that:
x:-1234, volume:10, pi:3.1415926535, name:test, str:hello
Are there some examples/libraries that do something like that? Note, I'm not limited on what c++ version to use (I use latest), but I will not use iostreams for sure.
#definereference could be helpful to read. Pay close attention to the#and##operators inside macro bodies.