CrossClj

1.0.1 docs

SourceDocs



RECENT
    VARS
    default-log-fn
    default-redact-key?
    default-request-keys
    make-transform-and-log-fn
    wrap-log-request-params
    wrap-log-request-start
    wrap-log-response
    wrap-with-logger

    « Index of all namespaces of this project

    Ring middleware to log each request, response, and parameters.
    
    (default-log-fn {:keys [level throwable message]})
    Set of keys redacted by default
    
    (make-transform-and-log-fn transform-fn log-fn)
    (wrap-log-request-params handler)(wrap-log-request-params handler {:keys [log-fn log-level transform-fn request-keys redact-key? redact-value-fn], :or {log-fn default-log-fn, transform-fn identity, log-level :debug, request-keys default-request-keys, redact-key? default-redact-key?, redact-value-fn (constantly "[REDACTED]")}})
    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}
    (wrap-log-request-start handler)(wrap-log-request-start handler {:keys [log-fn transform-fn request-keys], :or {log-fn default-log-fn, transform-fn identity, request-keys default-request-keys}})
    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]
    (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}})
    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
    (wrap-with-logger handler options)(wrap-with-logger handler)
    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}