Zero-dependency contextual and structured logging for fx effect pipelines.
Zero-dependency contextual and structured logging for fx effect pipelines.
(annotate-logs> annotations)(annotate-logs> prev-effect annotations)Injects structured metadata key-values into :fx.observability/log-annotations in the execution context.
All subsequent effects and log calls in the downstream pipeline will automatically inherit
these annotations.
Example: (-> (fx.observability.log/annotate-logs> {:request-id "req-123" :user-id 42}) (fx/mapcat> (fn [_] (fx.observability.log/log-info> "User logged in"))))
Injects structured metadata key-values into `:fx.observability/log-annotations` in the execution context.
All subsequent effects and log calls in the downstream pipeline will automatically inherit
these annotations.
Example:
(-> (fx.observability.log/annotate-logs> {:request-id "req-123" :user-id 42})
(fx/mapcat> (fn [_] (fx.observability.log/log-info> "User logged in"))))(console-logger-sink entry)Default console sink that formats and prints log entries to out (or err for :error).
Default console sink that formats and prints log entries to *out* (or *err* for :error).
(log-annotations-layer> annotations)Creates a Layer providing :fx.observability/log-annotations.
Creates a Layer providing `:fx.observability/log-annotations`.
(log-debug> message)(log-debug> a b)(log-debug> prev-effect message log-data)Creates a debug-level log effect.
Examples: (fx.observability.log/log-debug> "Cache hit" {:key "users:42"}) (-> (fetch-user 42) (fx.observability.log/log-debug> "Fetched user"))
Creates a debug-level log effect.
Examples:
(fx.observability.log/log-debug> "Cache hit" {:key "users:42"})
(-> (fetch-user 42)
(fx.observability.log/log-debug> "Fetched user"))(log-error> message)(log-error> a b)(log-error> prev-effect message log-data)Creates an error-level log effect.
Examples: (fx.observability.log/log-error> "Database connection failed" {:error (ex-message e)}) (-> (handle-failure err) (fx.observability.log/log-error> "Handled failure"))
Creates an error-level log effect.
Examples:
(fx.observability.log/log-error> "Database connection failed" {:error (ex-message e)})
(-> (handle-failure err)
(fx.observability.log/log-error> "Handled failure"))(log-info> message)(log-info> a b)(log-info> prev-effect message log-data)Creates an info-level log effect.
Examples: (fx.observability.log/log-info> "Server started" {:port 8080}) (-> (process-order order) (fx.observability.log/log-info> "Order processed"))
Creates an info-level log effect.
Examples:
(fx.observability.log/log-info> "Server started" {:port 8080})
(-> (process-order order)
(fx.observability.log/log-info> "Order processed"))(log-level-layer> level)Creates a Layer providing :fx.observability/log-level.
Creates a Layer providing `:fx.observability/log-level`.
(log-warn> message)(log-warn> a b)(log-warn> prev-effect message log-data)Creates a warn-level log effect.
Examples: (fx.observability.log/log-warn> "Rate limit threshold exceeded" {:current 95 :max 100}) (-> (retry-operation op) (fx.observability.log/log-warn> "Retrying operation"))
Creates a warn-level log effect.
Examples:
(fx.observability.log/log-warn> "Rate limit threshold exceeded" {:current 95 :max 100})
(-> (retry-operation op)
(fx.observability.log/log-warn> "Retrying operation"))(log> level message)(log> level-or-prev message-or-level data-or-message)(log> prev-effect level message log-data)Creates a structured log effect with the specified level, message, and optional log-data map.
When chained in an effect pipeline, preserves and propagates the upstream value.
Creates a structured log effect with the specified `level`, `message`, and optional `log-data` map. When chained in an effect pipeline, preserves and propagates the upstream value.
(logger-layer> sink-or-opts)(logger-layer> sink level)(logger-layer> sink level annotations)Creates a Layer providing :fx.observability/logger (and optionally :fx.observability/log-level and :fx.observability/log-annotations).
Accepts a logger sink function (e.g. console-logger-sink, system-logger-sink) or an options map
{:logger sink-fn :level :info :annotations {...}}.
Creates a Layer providing `:fx.observability/logger` (and optionally `:fx.observability/log-level` and `:fx.observability/log-annotations`).
Accepts a logger sink function (e.g. `console-logger-sink`, `system-logger-sink`) or an options map
`{:logger sink-fn :level :info :annotations {...}}`.(system-logger-sink entry)Java System.Logger sink (delegates to System.getLogger on JVM, console on JS).
Java System.Logger sink (delegates to System.getLogger on JVM, console on JS).
(with-log-level> level-or-eff eff-or-level)(with-log-level> prev-effect level target-eff)Executes effect with a scoped minimum log level (:debug, :info, :warn, :error).
Example: (fx.observability.log/with-log-level> :warn (noisy-pipeline>))
Executes `effect` with a scoped minimum log level (:debug, :info, :warn, :error). Example: (fx.observability.log/with-log-level> :warn (noisy-pipeline>))
(with-logger> logger-fn-or-eff eff-or-logger-fn)(with-logger> prev-effect logger-fn target-eff)Executes effect with a scoped custom log sink function (fn [log-entry] ...).
Example: (fx.observability.log/with-logger> custom-sink-fn (do-work>))
Executes `effect` with a scoped custom log sink function `(fn [log-entry] ...)`. Example: (fx.observability.log/with-logger> custom-sink-fn (do-work>))
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 |