how to log non 200 response

19 views
Skip to first unread message

vinurs

unread,
Jul 2, 2018, 4:01:58 AM7/2/18
to Luminus
In luminus, with schema, it can check request and response params, but it can only see in the end of APP or in web browser, is there any way that i can grab this error and log it, so i can know what occurred, i want to check this with middleware, but don't know how to do this 

Dmitri

unread,
Jul 3, 2018, 8:24:54 AM7/3/18
to Luminus
Hi, you could do something like the following with a middleware function:

(defn wrap-log-error [handler]
  (fn [request]
    (let [response (handler request)]
      (when (not= 200 (:status response))
        (log/error "error occurred processing " request))
      response)))


vinurs

unread,
Jul 3, 2018, 8:43:21 AM7/3/18
to Luminus
yes, thanks very much

在 2018年7月2日星期一 UTC+8下午4:01:58,vinurs写道:
Reply all
Reply to author
Forward
0 new messages