sail-riscv
sail-riscv copied to clipboard
Don't use `fprintf` for printing
People generate logs via fprintf is really ugly and diffcult to manage.
Yeah I also don't like fprintf. We could use iostreams but they also kind of suck. std::print is much nicer but only available in C++23. Maybe we just wait a few years...
Maybe things like spdlog?
I've used spdlog in the past. It's pretty good but has compilation time issues.
For the actual formatting it uses fmt which is basically what C++20/23 copied for std::format. I wonder if anyone has made some kind of polyfill for the actual std::format/print. That would probably be ideal.
How about libfmt, although it would add additional library dependency
Why is fprintf such a problem in a way that C++ equivalents aren’t? This feels like change for change’s sake.
It's not a big problem really. std::print/fmt::print is just a bit easier to use and more difficult to get wrong.
I would say it's fine to leave it for now and wait until C++23 is acceptable (2028?). But if someone really wants to add fmt I won't stop them...
I see something like zlog - you can edit your output format in config.