Fork me on GitHub
Ben Sless17:07:23

Hi all, What are the best practices regarding adding logging to libraries? How do I make logging backends pluggable from the user end while providing a sane default?



It provides a simple wrapper over a wide range of (Java) logging libraries in a way that lets users of your library control the implementation.

Ben Sless17:07:46

This simple? I don't need to provide anything besides?


Yup, you'll want to provide an implementation as a dependency in your tests for the library locally, and you'll want to note in the README that your library uses and expects users to provide an implementation.


For example, with next.jdbc, I have this in my :test alias to select an implementation for my tests:


(`next.jdbc` does not actually depend on org.clojure/tools.logging for day-to-day use, only for testing, but the principle is the same: you need an implementation for testing, but users can choose a different implementation)

Ben Sless18:07:02

Thank you very much, this answers all my questions regarding the subject 🙏