https://github.com/taoensso/trove
Modern logging facade for Clojure/Script
https://github.com/taoensso/trove
clojure clojurescript epl logging monitoring observability taoensso
Last synced: 12 months ago
JSON representation
Modern logging facade for Clojure/Script
- Host: GitHub
- URL: https://github.com/taoensso/trove
- Owner: taoensso
- License: epl-1.0
- Created: 2025-06-18T10:27:22.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-06-18T13:20:21.000Z (12 months ago)
- Last Synced: 2025-06-18T13:33:29.923Z (12 months ago)
- Topics: clojure, clojurescript, epl, logging, monitoring, observability, taoensso
- Language: Clojure
- Homepage: https://www.taoensso.com/trove
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: FUNDING.yml
- License: LICENSE.txt
- Security: SECURITY.md
Awesome Lists containing this project
README
[**API**][cljdoc] | [Slack channel][] | Latest release: [v1.0.0-beta2](../../releases/tag/v1.0.0-beta2) 🚧 (2025-06-20)
[![Clj tests][Clj tests SVG]][Clj tests URL]
[![Cljs tests][Cljs tests SVG]][Cljs tests URL]
[![Graal tests][Graal tests SVG]][Graal tests URL]
# Trove
### Modern logging facade for Clojure/Script
Trove is a minimal, modern alternative to [tools.logging](https://github.com/clojure/tools.logging) that supports:
- Both traditional **and structured** logging
- Both Clojure **and ClojureScript**
- **Richer filtering** capabilities (by namespace, id, level, data, etc.)
It's TINY (1 macro, 0 deps, ~100 loc), fast, and highly flexible.
It supports any backend including: [Telemere](https://www.taoensso.com/telemere), [Timbre](https://www.taoensso.com/timbre), [μ/log](https://github.com/BrunoBonacci/mulog), [tools.logging](https://github.com/clojure/tools.logging), [SLF4J](https://www.slf4j.org/), etc.
It works great for **library authors** that want to emit rich logging _without_ forcing their users to adopt any particular backend.
## To log
1. Include the (tiny) [dependency](../../releases/) in your project or library.
2. Use `trove/log!` to make your logging calls (see its [docstring](https://cljdoc.org/d/com.taoensso/trove/CURRENT/api/taoensso.trove#log!) for options):
```clojure
(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:
```clojure
(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.
## To choose a backend
Just set `trove/*log-fn*` to an appropriate fn (see its [docstring](https://cljdoc.org/d/com.taoensso/trove/CURRENT/api/taoensso.trove#*log-fn*) for fn args).
The default fn prints logs to `*out*` or the JS console.
Alt fns are also available for some common backends, e.g.:
```clojure
(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 `trove/log!` calls
```
It's easy to write your own log-fn if you want to use a different backend or customise anything.
## What about expensive data?
Structured logging sometimes involves expensive data collection or transformation, e.g.:
```clojure
(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*`](https://cljdoc.org/d/com.taoensso/trove/CURRENT/api/taoensso.trove#*log-fn*).
## Funding
You can [help support][sponsor] continued work on this project and [others][my work], thank you!! 🙏
## License
Copyright © 2025 [Peter Taoussanis][].
Licensed under [EPL 1.0](LICENSE.txt) (same as Clojure).
[GitHub releases]: ../../releases
[GitHub issues]: ../../issues
[GitHub wiki]: ../../wiki
[Slack channel]: https://www.taoensso.com/trove/slack
[Peter Taoussanis]: https://www.taoensso.com
[sponsor]: https://www.taoensso.com/sponsor
[my work]: https://www.taoensso.com/clojure-libraries
[cljdoc]: https://cljdoc.org/d/com.taoensso/trove/CURRENT/api/taoensso.trove
[Clojars SVG]: https://img.shields.io/clojars/v/com.taoensso/trove.svg
[Clojars URL]: https://clojars.org/com.taoensso/trove
[Clj tests SVG]: https://github.com/taoensso/trove/actions/workflows/clj-tests.yml/badge.svg
[Clj tests URL]: https://github.com/taoensso/trove/actions/workflows/clj-tests.yml
[Cljs tests SVG]: https://github.com/taoensso/trove/actions/workflows/cljs-tests.yml/badge.svg
[Cljs tests URL]: https://github.com/taoensso/trove/actions/workflows/cljs-tests.yml
[Graal tests SVG]: https://github.com/taoensso/trove/actions/workflows/graal-tests.yml/badge.svg
[Graal tests URL]: https://github.com/taoensso/trove/actions/workflows/graal-tests.yml