better logging
This commit is contained in:
parent
11ad43675f
commit
1ec46b5407
@ -1,4 +1,4 @@
|
||||
(defproject bitgloo-web "0.4"
|
||||
(defproject bitgloo-web "0.5"
|
||||
:description "bitgloo website framework"
|
||||
:url "https://bitgloo.com"
|
||||
:license {:name "GPL-3.0-or-later" :url "https://www.gnu.org/licenses/gpl-3.0.en.html"}
|
||||
|
@ -35,15 +35,20 @@
|
||||
(fn [request]
|
||||
(when (= :get (:request-method request)) (handler request))))
|
||||
|
||||
(defn wrap-log-request [handler]
|
||||
(defn wrap-log-transactions [handler]
|
||||
(fn [request]
|
||||
(-> request
|
||||
(select-keys [:headers :protocol :request-method :uri])
|
||||
(update :headers get "x-forwarded-for")
|
||||
(vals)
|
||||
(conj "request:")
|
||||
((partial apply println)))
|
||||
(handler request)))
|
||||
(let [response (handler request)]
|
||||
(println
|
||||
(get-in request [:headers "x-forwarded-for"])
|
||||
"-"
|
||||
(str (java.util.Date.))
|
||||
"-"
|
||||
(:request-method request)
|
||||
(:uri request)
|
||||
(:protocol request)
|
||||
"-"
|
||||
(:status response))
|
||||
response)))
|
||||
|
||||
(defn wrap-not-found [handler] (fn [request] (or (handler request) not-found)))
|
||||
|
||||
@ -58,7 +63,7 @@
|
||||
(wrap-not-modified)
|
||||
(wrap-only-gets)
|
||||
(wrap-not-found)
|
||||
(wrap-log-request)
|
||||
(wrap-log-transactions)
|
||||
(run-jetty {:port port})))
|
||||
(println "usage: bitgloo port content-path")))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user