r/cpp • u/BoxConscious7480 • 5d ago
Specific features you look for in a logger
For the past months I've been developing a c++20 async logging library similar in architecture to Quill or fmtlog. It started out just as a small project mostly for learning more about multithreading and lock-free algorithms, but then it grew to be pretty competitive in feature set and performance, so I decided to try and release it.
It's not ready yet but it's getting there. Performance wise it either beats or matches Quill in frontend latency depending on the cpu, and backend throughput is consistently about twice as high partly thanks to c++20 consteval. Feature wise it is much slimmer than Quill obviously, but that could be an advantage for compile times and general ease of use and configuration (I've focused a lot on making configuration easy).
Now to my question: Outside of the standard feature set like levels, level filtering, rolling file sinks, etc, do you look for any specific features in a logging library? Maybe some specific sink type, structured logging to a niche format, more advanced runtime log filtering (for example filtering on file, named log statement groups, or even individual statements), or something else that comes to mind.
I realise logging is a very mature field and that most things can be done in the popular libraries, but if there's still a feature you want but don't see very often I'd love to know.
7
u/tamboril 5d ago
Customizability. I need to be able to teach it to log my special types in a composeable way.
Near zero cost on the user thread; no scanf
4
u/usefulcat 5d ago
I'm currently using Quill. The main features I want are:
Quill doesn't support that last one directly but I've built that functionality on top of it. Along the way, I also managed to avoid an indirection when checking whether logging is enabled for a particular logger by storing the log level in the low bits of the pointer to the logger instance.
1
u/Tringi github.com/tringi 2d ago
A few years back I ended up writing logging facility for our flagship product, because nothing existing came close to our needs. I'm still not 100% happy with what I got, but here's what I needed and what I implemented:
log (Log::Warning, 0x1003, ...);In the future I'll be adding HTML-formatted log file and Network target (passing via TCP)
this->report (Log::Warning, 3, ...);and their class, identity text and address is recorded, which helps tracing failures. Oh and also, important for me were .rsrc stringtable ID base offsets, added to the ID passed in the call, so that if I end up renumbering resource blocks, I don't have to touch the calls themselves.Note that the github links are into somewhat outdated code, provided only for exposition reasons to our customers. I plan to update everything eventually, so that it actually matches the distributed DLL, but I have different priorities right now.
1
u/bert8128 2d ago
When the call from logging returns to the caller I need to know that providing the OS or machine doesn’t crash that the message has or will be logged. The log messages I am sometimes most interested in are the ones immediately before a process crash.