log4cats icon indicating copy to clipboard operation
log4cats copied to clipboard

Support for a safe way to defer logging on the happy path

Open morgen-peschke opened this issue 9 months ago • 0 comments

A "that would be nice" feature that's come up occasionally when discussing logging is the ability to log only when an error condition is encountered.

We can get basically this in tests using TestingLogger/StructuredTestingLogger and it would be really handy to be able to do this in production code as well.

I think there's a path to a reasonable implementation using Ref, but I'm not sure if there isn't a more elegant way to handle a logger's lifecycle (particularly in the context of an http4s request).

I haven't poked at how this would work with LoggerFactory, which may have it's own complications.

morgen-peschke avatar Apr 30 '24 23:04 morgen-peschke