observability

o11y, monitoring, logging, tracing, alerting and higher level discussions
Ben Sless 2020-07-07T17:19:23.081Z

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?

seancorfield 2020-07-07T17:24:04.081200Z

clojure.tools.logging

seancorfield 2020-07-07T17:24:41.082Z

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 Sless 2020-07-07T17:25:46.082400Z

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

seancorfield 2020-07-07T17:33:23.083500Z

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 clojure.tools.logging and expects users to provide an implementation.

seancorfield 2020-07-07T17:34:33.084100Z

For example, with next.jdbc, I have this in my :test alias to select an implementation for my tests: https://github.com/seancorfield/next-jdbc/blob/develop/deps.edn#L28-L35

seancorfield 2020-07-07T17:35:24.085200Z

(`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 Sless 2020-07-07T18:10:02.085700Z

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