(default-ex-data-field-fn f)
Default function to pre-process fields in ex-info data map. This default implementation simply passes the field value through. A common use case might be to strip non-Serializable values from the ex-info data map. While exceptions with non-Serializable fields won't prevent logging, they will prevent successful JSON parsing and will use the fallback logger.
An :ex-data-field-fn
of
(fn [f] (when (instance? java.io.Serializable f) f))
would replace the non-Serializable values with nils.
Default function to pre-process fields in ex-info data map. This default implementation simply passes the field value through. A common use case might be to strip non-Serializable values from the ex-info data map. While exceptions with non-Serializable fields won't prevent logging, they will prevent successful JSON parsing and will use the fallback logger. An `:ex-data-field-fn` of ``` (fn [f] (when (instance? java.io.Serializable f) f)) ``` would replace the non-Serializable values with nils.
Default key names in the log map
Default key names in the log map
(default-should-log-field-fn field-name {:keys [?err] :as _data})
Default function to determine whether to log fields.
Logs all fields except :file :line and :ns which are only logged on error.
Default function to determine whether to log fields. Logs all fields except :file :line and :ns which are only logged on error.
(handle-vargs log-map ?msg-fmt vargs inline-args? msg-key)
Handles varg parsing, adding the msg and the given context to the given log map.
If inline-args is true, then the remaining vargs are added to :args, otherwise they're inlined into the log-map.
Handles varg parsing, adding the msg and the given context to the given log map. If inline-args is true, then the remaining vargs are added to :args, otherwise they're inlined into the log-map.
(install)
(install {:keys [level min-level pretty inline-args? level-key msg-key
should-log-field-fn ex-data-field-fn key-names]
:or {level-key :level
pretty false
inline-args? true
msg-key :msg
should-log-field-fn default-should-log-field-fn
ex-data-field-fn default-ex-data-field-fn
key-names default-key-names}})
Installs json-appender as the sole appender for Timbre, options
level
: Timbre log level (deprecated, prefer min-level)
min-level
: Timbre log level
level-key
: The key to use for log-level
msg-key
: The key to use for the message (default :msg)
pretty
: Pretty-print JSON
inline-args?
: Place arguments on top level, instead of placing behind args
field
should-log-field-fn
: A function which determines whether to log the given top-level field. Defaults to default-should-log-field-fn
ex-data-field-fn
: A function which pre-processes fields in the ex-info data map. Useful when ex-info data map includes non-Serializable values. Defaults to default-ex-data-field-fn
key-names
: Map of log key names. Can be used to override the default key names in default-key-names
Installs json-appender as the sole appender for Timbre, options `level`: Timbre log level (deprecated, prefer min-level) `min-level`: Timbre log level `level-key`: The key to use for log-level `msg-key`: The key to use for the message (default :msg) `pretty`: Pretty-print JSON `inline-args?`: Place arguments on top level, instead of placing behind `args` field `should-log-field-fn`: A function which determines whether to log the given top-level field. Defaults to `default-should-log-field-fn` `ex-data-field-fn`: A function which pre-processes fields in the ex-info data map. Useful when ex-info data map includes non-Serializable values. Defaults to `default-ex-data-field-fn` `key-names`: Map of log key names. Can be used to override the default key names in `default-key-names`
(json-appender)
(json-appender {:keys [inline-args?] :or {inline-args? false} :as config})
Creates Timbre configuration map for JSON appender that prints to STDOUT
Creates Timbre configuration map for JSON appender that prints to STDOUT
(make-json-output-fn)
(make-json-output-fn {:keys [pretty inline-args? level-key msg-key
should-log-field-fn ex-data-field-fn key-names]
:or {pretty false
inline-args? true
should-log-field-fn default-should-log-field-fn
ex-data-field-fn default-ex-data-field-fn
key-names default-key-names}})
Creates a Timbre output-fn that prints JSON strings. Takes the following options:
level-key
: The key to use for log-level
msg-key
: The key to use for the message (default :msg)
pretty
: Pretty-print JSON
inline-args?
: Place arguments on top level, instead of placing behind args
field
should-log-field-fn
: A function which determines whether to log the given top-level field. Defaults to default-should-log-field-fn
ex-data-field-fn
: A function which pre-processes fields in the ex-info data map. Useful when ex-info data map includes non-Serializable values. Defaults to default-ex-data-field-fn
key-names
: Map of log key names. Can be used to override the default key names in default-key-names
Creates a Timbre output-fn that prints JSON strings. Takes the following options: `level-key`: The key to use for log-level `msg-key`: The key to use for the message (default :msg) `pretty`: Pretty-print JSON `inline-args?`: Place arguments on top level, instead of placing behind `args` field `should-log-field-fn`: A function which determines whether to log the given top-level field. Defaults to `default-should-log-field-fn` `ex-data-field-fn`: A function which pre-processes fields in the ex-info data map. Useful when ex-info data map includes non-Serializable values. Defaults to `default-ex-data-field-fn` `key-names`: Map of log key names. Can be used to override the default key names in `default-key-names`
(wrap-json-logging handler)
Ring middleware for JSON logging. Logs :method, :uri and :status for successful handler invocations, :method and :uri for failed invocations.
Ring middleware for JSON logging. Logs :method, :uri and :status for successful handler invocations, :method and :uri for failed invocations.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close