Hand-rolled cross-platform logging (no Timbre/SLF4J).
Level macros: trace, debug, info, warn, error, fatal, report.
Level controls: off!, fatal!, error!, warn!, info!, debug!, all!,
level, set-level!, with-level.
Test helpers: capture-logs (macro), parse-captured-logs, captured-logs-str.
Raw @captured-logs holds maps {:level :message} — not a stable public layout;
prefer the parse helpers in tests.
Levels (ascending severity): :trace < :debug < :info < :warn < :error < :fatal < :report.
A call is emitted when its level is ≥ the configured minimum (default :info).
When a call is suppressed, its arguments are not evaluated (macros wrap args in when).
Implementation dynamics (*min-level-override*, *capturing?*) and -emit! are not part of
the supported API — use the macros and level helpers.
Hand-rolled cross-platform logging (no Timbre/SLF4J).
Level macros: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `report`.
Level controls: `off!`, `fatal!`, `error!`, `warn!`, `info!`, `debug!`, `all!`,
`level`, `set-level!`, `with-level`.
Test helpers: `capture-logs` (macro), `parse-captured-logs`, `captured-logs-str`.
Raw `@captured-logs` holds maps `{:level :message}` — not a stable public layout;
prefer the parse helpers in tests.
Levels (ascending severity): :trace < :debug < :info < :warn < :error < :fatal < :report.
A call is emitted when its level is ≥ the configured minimum (default :info).
When a call is suppressed, its arguments are not evaluated (macros wrap args in `when`).
Implementation dynamics (`*min-level-override*`, `*capturing?*`) and `-emit!` are not part of
the supported API — use the macros and level helpers.(-emit! lvl args)Internal emit path. Prefer level macros. Defensive may-log? check; macros are responsible for not evaluating args when suppressed.
Internal emit path. Prefer level macros. Defensive may-log? check; macros are responsible for not evaluating args when suppressed.
(-nanos)(-platform-time)(all!)(capture-logs & body)Clear capture buffer, force min-level :trace for body, capture without printing. Restores previous global min-level afterward (not a dynamic with-level override).
Clear capture buffer, force min-level :trace for body, capture without printing. Restores previous *global* min-level afterward (not a dynamic with-level override).
(capture-logs* f)Runtime implementation of capture-logs. Restores the global atom min-level (not the effective level), so nesting under with-level does not pollute the atom.
Runtime implementation of capture-logs. Restores the global atom min-level (not the effective level), so nesting under with-level does not pollute the atom.
Atom buffer of captured log maps. Prefer parse-captured-logs / captured-logs-str.
Atom buffer of captured log maps. Prefer parse-captured-logs / captured-logs-str.
(captured-logs-str)Newline-joined message strings from the capture buffer.
Newline-joined message strings from the capture buffer.
(color-pr message color)For ANSI color codes: https://en.wikipedia.org/wiki/ANSI_escape_code
For ANSI color codes: https://en.wikipedia.org/wiki/ANSI_escape_code
(debug & args)(debug!)(error & args)(error!)(fatal & args)(fatal!)(info & args)(info!)(level)Current effective minimum log level (dynamic override wins over global atom).
Current effective minimum log level (dynamic override wins over global atom).
(may-log? lvl)true when a call at lvl should be emitted under the current min-level. Safe for callers to use when guarding expensive work outside log macros.
true when a call at lvl should be emitted under the current min-level. Safe for callers to use when guarding expensive work outside log macros.
(off!)(parse-captured-logs)Return captured entries as ({:level … :message …} …).
Return captured entries as ({:level … :message …} …).
(report & args)(set-level! new-level)Set global min-level. When the effective level changes, report "Setting log level: …".
Note: under with-level, the dynamic override still wins until the binding exits;
bang helpers update the global atom, which takes effect after with-level.
Set global min-level. When the *effective* level changes, report "Setting log level: …". Note: under `with-level`, the dynamic override still wins until the binding exits; bang helpers update the global atom, which takes effect after `with-level`.
(table-spec & cols)(test-levels msg)(time expr)Same as clojure.core/time but logs (info) instead of printing elapsed time.
Same as clojure.core/time but logs (info) instead of printing elapsed time.
(trace & args)(warn & args)(warn!)(with-level level & body)Run body with a temporary min-level override (dynamic).
Run body with a temporary min-level override (dynamic).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |