(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 json-error-fn
pretty-array]
:or {pretty false
inline-args? true
key-names default-key-names
msg-key :msg
level-key :level
should-log-field-fn default-should-log-field-fn
ex-data-field-fn default-ex-data-field-fn
json-error-fn (fn [_t])
pretty-array false}})
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
pretty-array:
Use a PrettyPrinter that makes more compact nested arrays
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-error-fn:
Function to call if JSON serialization fails. Takes a single argument, a Throwable.
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 `pretty-array:` Use a PrettyPrinter that makes more compact nested arrays `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-error-fn:` Function to call if JSON serialization fails. Takes a single argument, a Throwable.
(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
json-error-fn pretty-array]
:or {pretty false
pretty-array 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
json-error-fn (fn [_t])}})
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
pretty-array:
Use a PrettyPrinter that makes more compact nested arrays
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-error-fn:
Function to call if JSON serialization fails. Takes a single argument, a Throwable.
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 `pretty-array:` Use a PrettyPrinter that makes more compact nested arrays `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-error-fn:` Function to call if JSON serialization fails. Takes a single argument, a Throwable.
(make-pretty-printer)
Creates a PrettyPrinter that produces compact output for nested arrays, which makes stack traces represented by Throwable->map easier to read
Creates a PrettyPrinter that produces compact output for nested arrays, which makes stack traces represented by Throwable->map easier to read
(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