Liking cljdoc? Tell your friends :D

ring.logger

Ring middleware to log each request, response, and parameters.

Ring middleware to log each request, response, and parameters.
raw docstring

default-log-fnclj

(default-log-fn {:keys [level throwable message]})
source

default-redact-key?clj

Set of keys redacted by default

Set of keys redacted by default
sourceraw docstring

default-request-keysclj

source

make-transform-and-log-fnclj

(make-transform-and-log-fn transform-fn log-fn)
source

wrap-log-request-paramsclj

(wrap-log-request-params handler)
(wrap-log-request-params handler options)

Ring middleware to log the parameters from each request

Parameters are redacted by default, replacing the values that correspond to certain keys to "[REDACTED]". This is to prevent sensitive information from being written out to logs.

Options may include:

  • log-fn: used to do the actual logging. Accepts a map with keys [level throwable message]. Defaults to clojure.tools.logging/log.
  • transform-fn: transforms a log item before it is passed through to log-fn. Messsage type it needs to handle: :params. It can filter messages by returning nil. Receives a map (a log item) with keys: [:level :throwable :message].
  • request-keys: Keys from the request that will be logged (unchanged) in addition to the data that ring.logger adds like [::type :params]. Defaults to [:request-method :uri :server-name]
  • redact-key?: fn that is called on each key in the params map to check whether its value should be redacted. Receives the key, returns truthy/falsy. A common pattern is to use a set. Default value: #{:authorization :password :token :secret :secret-key :secret-token}
Ring middleware to log the parameters from each request

Parameters are redacted by default, replacing the values that correspond to
certain keys to "[REDACTED]". This is to prevent sensitive information from
being written out to logs.

Options may include:

  * log-fn: used to do the actual logging. Accepts a map with keys
            [level throwable message]. Defaults to `clojure.tools.logging/log`.
  * transform-fn: transforms a log item before it is passed through to log-fn. Messsage
            type it needs to handle: :params. It can filter messages by returning nil.
            Receives a map (a log item) with keys: [:level :throwable :message].
  * request-keys: Keys from the request that will be logged (unchanged) in addition to
            the data that ring.logger adds like [::type :params].
            Defaults to [:request-method :uri :server-name]
  * redact-key?: fn that is called on each key in the params map to check whether its
            value should be redacted. Receives the key, returns truthy/falsy. A common
            pattern is to use a set.
            Default value: #{:authorization :password :token :secret :secret-key :secret-token}
sourceraw docstring

wrap-log-request-startclj

(wrap-log-request-start handler)
(wrap-log-request-start handler options)

Ring middleware to log basic information about a request.

Adds the key :ring.logger/start-ms to the request map

Options may include:

  • log-fn: used to do the actual logging. Accepts a map with keys [level throwable message]. Defaults to clojure.tools.logging/log.
  • transform-fn: transforms a log item before it is passed through to log-fn. Messsage types it might need to handle: [:starting]. It can filter messages by returning nil. Receives a map (a log item) with keys: [:level :throwable :message].
  • request-keys: Keys from the request that will be logged (unchanged) in addition to the data that ring.logger adds like [::type ::ms :status]. Defaults to [:request-method :uri :server-name]
Ring middleware to log basic information about a request.

Adds the key :ring.logger/start-ms to the request map

Options may include:

  * log-fn: used to do the actual logging. Accepts a map with keys
            [level throwable message]. Defaults to `clojure.tools.logging/log`.
  * transform-fn: transforms a log item before it is passed through to log-fn. Messsage types
            it might need to handle: [:starting]. It can filter messages by returning nil.
            Receives a map (a log item) with keys: [:level :throwable :message].
  * request-keys: Keys from the request that will be logged (unchanged) in addition to the data
            that ring.logger adds like [::type ::ms :status].
            Defaults to [:request-method :uri :server-name]
sourceraw docstring

wrap-log-responseclj

(wrap-log-response handler)
(wrap-log-response handler
                   {:keys [log-fn log-exceptions? transform-fn request-keys]
                    :or {log-fn default-log-fn
                         transform-fn identity
                         log-exceptions? true
                         request-keys default-request-keys}
                    :as options})

Ring middleware to log response and timing for each request.

Takes the starting timestamp (in msec.) from the :ring.logger/start-ms key in the request map, or System/currentTimeMillis if that key is not present.

Options may include:

  • log-fn: used to do the actual logging. Accepts a map with keys [level throwable message]. Defaults to clojure.tools.logging/log.
  • transform-fn: transforms a log item before it is passed through to log-fn. Messsage types it might need to handle: [:finish :exception]. It can filter messages by returning nil. Receives a map (a log item) with keys: [:level :throwable :message].
  • request-keys: Keys from the request that will be logged (unchanged) in addition to the data that ring.logger adds like [::type ::ms :status]. Defaults to [:request-method :uri :server-name]
  • log-exceptions?: When true, logs exceptions as an :error level message, rethrowing the original exception. Defaults to true
  • status-to-log-level-fn: A function that receives the response status as a number, and returns the log level. By default, <= 500 are :error, rest are :info.
Ring middleware to log response and timing for each request.

Takes the starting timestamp (in msec.) from the :ring.logger/start-ms key in
the request map, or System/currentTimeMillis if that key is not present.

Options may include:

  * log-fn: used to do the actual logging. Accepts a map with keys
            [level throwable message]. Defaults to `clojure.tools.logging/log`.
  * transform-fn: transforms a log item before it is passed through to log-fn. Messsage types
            it might need to handle: [:finish :exception]. It can filter messages by
            returning nil. Receives a map (a log item) with keys: [:level :throwable :message].
  * request-keys: Keys from the request that will be logged (unchanged) in addition to the data
            that ring.logger adds like [::type ::ms :status].
            Defaults to [:request-method :uri :server-name]
  * log-exceptions?: When true, logs exceptions as an :error level message, rethrowing
            the original exception. Defaults to true
  * status-to-log-level-fn: A function that receives the response status as a number, and returns
            the log level. By default, <= 500 are :error, rest are :info.
sourceraw docstring

wrap-with-loggerclj

(wrap-with-logger handler)
(wrap-with-logger handler options)

Returns a ring middleware handler to log arrival, response, and parameters for each request.

Log messages are simple clojure maps that can be transformed to a different representation (string, JSON, etc.) via the transform-fn option

Options may include:

  • log-fn: used to do the actual logging. Accepts a map with keys [level throwable message]. Defaults to clojure.tools.logging/log.
  • transform-fn: transforms a log item before it is passed through to log-fn. Messsage types it might need to handle: [:starting :params :finish :exception]. It can filter log items by returning nil. Log items are maps with keys: [:level :throwable :message].
  • request-keys: Keys from the request that will be logged (unchanged) in addition to the data that ring.logger adds like [::type ::ms]. Defaults to [:request-method :uri :server-name]
  • log-exceptions?: When true, logs exceptions as an :error level message, rethrowing the original exception. Defaults to true
  • redact-key?: fn that is called on each key in the params map to check whether its value should be redacted. Receives the key, returns truthy/falsy. A common pattern is to use a set. Default value: #{:authorization :password :token :secret :secret-key :secret-token}
  • status-to-log-level-fn: A function that receives the response status as a number, and returns the log level. By default, <= 500 are :error, rest are :info.
Returns a ring middleware handler to log arrival, response, and parameters
for each request.

Log messages are simple clojure maps that can be transformed to a different
representation (string, JSON, etc.) via the transform-fn option

Options may include:

  * log-fn: used to do the actual logging. Accepts a map with keys
            [level throwable message]. Defaults to `clojure.tools.logging/log`.
  * transform-fn: transforms a log item before it is passed through to log-fn. Messsage types
            it might need to handle: [:starting :params :finish :exception]. It can filter
            log items by returning nil. Log items are maps with keys: [:level :throwable :message].
  * request-keys: Keys from the request that will be logged (unchanged) in addition to the data
            that ring.logger adds like [::type ::ms].
            Defaults to [:request-method :uri :server-name]
  * log-exceptions?: When true, logs exceptions as an :error level message, rethrowing
            the original exception. Defaults to true
  * redact-key?: fn that is called on each key in the params map to check whether its
            value should be redacted. Receives the key, returns truthy/falsy. A common
            pattern is to use a set.
            Default value: #{:authorization :password :token :secret :secret-key :secret-token}
  * status-to-log-level-fn: A function that receives the response status as a number, and returns
            the log level. By default, <= 500 are :error, rest are :info.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close