Skip to content

Error in cookbook custom log format example #170

@wtfleming

Description

@wtfleming

At http://pedestal.io/cookbook/index#_custom_log_format

In the code example

(def log-request
  "Logs all http requests with response time."
  {:name ::log-request
   :enter (fn [context]
              (assoc-in context [:request :start-time] (System/currentTimeMillis)))
   :leave (fn [context]
              (let [{:keys [uri start-time request-method]} (:request context)
                    finish (System/currentTimeMillis)
                    total (- finish start-time)]
                   (log/info :msg "request completed"
                             :method (clojure.string/upper-case (name request-method))
                             :uri uri
                             :status (:status (:response context))
                             :response-time total)))})

The function associated with :leave should return context?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions