API | Slack channel | Latest release: v1.0.0-beta2 🚧 (2025-06-20)
Trove is a minimal, modern alternative to tools.logging that supports:
It's TINY (1 macro, 0 deps, ~100 loc), fast, and highly flexible.
It supports any backend including: Telemere, Timbre, μ/log, tools.logging, SLF4J, etc.
It works great for library authors that want to emit rich logging without forcing their users to adopt any particular backend.
trove/log!
to make your logging calls (see its docstring for options):(ns my-ns (:require [taoensso.trove :as trove]))
(trove/log! {:level :info, :id :auth/login, :data {:user-id 1234}, :msg "User logged in!"})
The above logging call expands to:
(when-let [log-fn trove/*log-fn*] ; Chosen backend fn
(log-fn ... "my-ns" :info :auth/login [line-num column-num]
{:msg "User logged in!", :data {:user-id 1234}} ...))
And the chosen backend then takes care of filtering and output.
Just set trove/*log-fn*
to an appropriate fn (see its docstring for fn args).
The default fn prints logs to *out*
or the JS console.
Alts are also available for some common backends, e.g.:
(ns my-ns
(:require
[taoensso.trove.x] ; x ∈ #{console telemere timbre mulog tools-logging slf4j} (default console)
[taoensso.trove :as trove]))
(trove/set-log-fn! (taoensso.trove.x/get-log-fn))
(trove/set-log-fn! nil) ; To noop all `log!` calls
It's easy to write your own log-fn if you want to use a different backend or customise anything.
Structured logging sometimes involves expensive data collection or transformation, e.g.:
(trove/log! {:id ::my-event, :data (expensive) ...})
That's why Trove automatically delays any values that need runtime evaluation, allowing the backend to apply filtering before paying realization costs.
This explains the :lazy_
{:keys [msg data error kvs]}
arg given to truss/*log-fn*
.
You can help support continued work on this project and others, thank you!! 🙏
Copyright © 2025 Peter Taoussanis.
Licensed under EPL 1.0 (same as Clojure).
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close