Random utils, opinionated logging support functions.
Random utils, opinionated logging support functions.
When true, indicates the current exception has already been logged and should not be logged again by outer handlers.
When `true`, indicates the current exception has already been logged and should not be logged again by outer handlers.
(dbg msg & more)Logs a space-joined message at DEBUG level using some-str-spc.
Logs a space-joined message at DEBUG level using `some-str-spc`.
(debug msg-or-throwable)(debug mdc-or-throwable msg)(debug mdc throwable msg)Logs a message at DEBUG level.
Logs a message at DEBUG level.
Default logging configuration map: INFO level with console output enabled.
Default logging configuration map: INFO level with console output enabled.
(err msg & more)Logs a space-joined message at ERROR level using some-str-spc.
Logs a space-joined message at ERROR level using `some-str-spc`.
(err-with-val msg & more)Logs msg (and optional extra parts) at ERROR level. When extra arguments are
present, the last one is returned as the expression value.
Logs `msg` (and optional extra parts) at ERROR level. When extra arguments are present, the last one is returned as the expression value.
(error msg-or-throwable)(error mdc-or-throwable msg)(error mdc throwable msg)Logs a message at ERROR level.
Logs a message at ERROR level.
(fatal msg-or-throwable)(fatal mdc-or-throwable msg)(fatal mdc throwable msg)Logs a message at FATAL level.
Logs a message at FATAL level.
(info msg-or-throwable)(info mdc-or-throwable msg)(info mdc throwable msg)Logs a message at INFO level.
Logs a message at INFO level.
(init! config)Initialises the logging subsystem. Snapshots the current Logback state, detaches
previously installed appenders, configures the JSON decoder and the context
transformer, then starts unilog. Returns a map with :config,
:previous-ctx-transformer, :previous-logback, and :unilog keys suitable for
passing to stop! to restore the prior state.
Initialises the logging subsystem. Snapshots the current Logback state, detaches previously installed appenders, configures the JSON decoder and the context transformer, then starts unilog. Returns a map with `:config`, `:previous-ctx-transformer`, `:previous-logback`, and `:unilog` keys suitable for passing to `stop!` to restore the prior state.
(initialize-context-transformer! transform-map)Installs a cambium context transformer derived from transform-map.
Returns the previous transformer (or nil if nothing changed).
Installs a cambium context transformer derived from `transform-map`. Returns the previous transformer (or nil if nothing changed).
(initialize-json-decoder!)Configures the JSON decoder for structured logging: enables big-decimal parsing,
installs the cambium destringify codec and sets the global FlatJsonLayout decoder.
Configures the JSON decoder for structured logging: enables big-decimal parsing, installs the cambium destringify codec and sets the global `FlatJsonLayout` decoder.
(log level msg-or-throwable)(log logger level msg-or-throwable)(log level mdc throwable msg)(log logger level mdc-or-throwable throwable msg)Logs a message at the given level. Delegates to cambium.core/log.
Logs a message at the given `level`. Delegates to `cambium.core/log`.
(log-context context & body)Evaluates body with additional MDC logging context (a map).
Evaluates `body` with additional MDC logging `context` (a map).
(log-exceptions & body)Wraps body in a try/catch that logs any Throwable at ERROR level (with the
exception stringified in the MDC context) and re-throws it with *already-logged*
bound to true so outer handlers can avoid duplicate logging.
Wraps `body` in a try/catch that logs any `Throwable` at ERROR level (with the exception stringified in the MDC context) and re-throws it with `*already-logged*` bound to `true` so outer handlers can avoid duplicate logging.
(msg msg & more)Logs a space-joined message at INFO level using some-str-spc.
Logs a space-joined message at INFO level using `some-str-spc`.
(msg-with-val msg & more)Logs msg (and optional extra parts) at INFO level. When extra arguments are
present, the last one is returned as the expression value.
Logs `msg` (and optional extra parts) at INFO level. When extra arguments are present, the last one is returned as the expression value.
(preprocess-config config)Pre-processes logging config by expanding Java property placeholders in :file
paths of each appender entry. Marks the config as :preprocessed to avoid
repeated processing. Returns config unchanged when no :appenders key is present
or the config has already been preprocessed.
Pre-processes logging `config` by expanding Java property placeholders in `:file` paths of each appender entry. Marks the config as `:preprocessed` to avoid repeated processing. Returns `config` unchanged when no `:appenders` key is present or the config has already been preprocessed.
(start! config)Starts the logging subsystem by delegating to unilog/start-logging! with the
given config map.
Starts the logging subsystem by delegating to `unilog/start-logging!` with the given `config` map.
(stop! {:keys [previous-ctx-transformer previous-logback]})Tears down the logging subsystem and restores the state captured by init!.
Detaches appenders prefixed with "io.randomseed.utils.log.", restores the
previous context transformer and the previous Logback snapshot. Returns nil.
Tears down the logging subsystem and restores the state captured by `init!`. Detaches appenders prefixed with `"io.randomseed.utils.log."`, restores the previous context transformer and the previous Logback snapshot. Returns `nil`.
(trace msg-or-throwable)(trace mdc-or-throwable msg)(trace mdc throwable msg)Logs a message at TRACE level.
Logs a message at TRACE level.
(warn msg-or-throwable)(warn mdc-or-throwable msg)(warn mdc throwable msg)Logs a message at WARN level.
Logs a message at WARN level.
(warning msg-or-throwable)(warning mdc-or-throwable msg)(warning mdc throwable msg)Alias for warn. Logs a message at WARN level.
Alias for `warn`. Logs a message at WARN level.
(with-ctx context & body)Alias for log-context. Evaluates body with additional MDC logging context.
Alias for `log-context`. Evaluates `body` with additional MDC logging `context`.
(wrn msg & more)Logs a space-joined message at WARN level using some-str-spc.
Logs a space-joined message at WARN level using `some-str-spc`.
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 |