r/cpp • • 2d 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.

0 Upvotes

7 comments sorted by

7

u/tamboril 2d 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

-1

u/BoxConscious7480 2d ago

Hmm curious what you mean by composeable here?

2

u/tamboril 2d ago

It should be trivial for me to write a log adapter for StructB, which contains only an instance of StructA (and primitive types), if I've already declared a log adapter for StructA.

1

u/BoxConscious7480 4h ago

Ok that's what I figured thanks! This is definitely a planned feature

1

u/homeless_psychopath 2d ago

It probably means constructing something from different objects with different types

4

u/usefulcat 2d ago

I'm currently using Quill. The main features I want are:

  • as much work as possible deferred to a dedicated logging thread
  • minimal latency at log site
  • support for custom types
  • hierarchical logging, e.g. if I enable logging for logger "log1", I also get logging for "log1.a", "log1.b", etc but not for "log2".

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/BoxConscious7480 2d ago

That’s interesting. My library doesn’t really have the concept of different “loggers” in the same way Quill and a lot of other libraries do.

The advantage is simplicity in architecture and configuration, but it also means that all log statements are configured the same way and can’t for example be piped to different sinks.

I am thinking of a tag/group system though, that would allow you to filter out groups of log statements at runtime similar to how you described. I guess it could be made hierarchical somehow