amperity / dialog

Simple just-enough logging library for Clojure
MIT License
39 stars 2 forks source link

Dialog

CircleCI codecov cljdoc badge Clojars Project

Dialog is a simple and opinionated logging library that implements an SLF4J-compatible backend in Clojure. This means it is compatible with a wide variety of logging APIs, including clojure.tools.logging and most Java libraries.

Inspired by the fallout from the log4shell vulnerability, and the question "what if we wrote just enough code to do the kinds of logging we want?". This is an attempt to produce a minimally-configurable logging backend that is nonetheless still extensible in a few ways - in particular, it aims to be easy to integrate with ken as an extension to observability tooling.

Usage

Releases are published on Clojars. You can use the latest Maven coordinate, or point at the main branch using deps.edn.

By default, this will pull in the SLF4J API package as well as redirecting java.util.logging, commons-logging, and log4j classes to SLF4J. For more information, see the SLF4J legacy bridging documentation.

Within your code, you can use the standard clojure.tools.logging approach to logging and things should Just Work. If for some reason you don't want to pull in org.clojure/tools.logging, the dialog.logger namespace contains a set of compatible macros such as logp, debug, infof, etc.

The dialog.logger namespace also contains a number of utility functions which can be used to inspect and dynamically adjust the logging configuration at runtime.

Configuration

At initialization time, dialog will try to read configuration from a resource named dialog.edn. This is an aero file which should contain a map telling dialog how to behave. See the configuration docs for more information, or check out the sample config in this repo for a comprehensive example.

Development

This library uses Clojure's CLI and deps.edn to manage and build the project. See the development docs for detailed instructions.

License

Copyright © 2023 Amperity, Inc.

Distributed under the MIT License.