aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-05-22 10:28:21 -0400
committerClyne Sullivan <clyne@bitgloo.com>2023-05-22 10:28:21 -0400
commit1ec46b5407ac719bc85019a791511d0f5df1d6f5 (patch)
tree7e10482c942dedf69b1182fec7f9e10e7e626ccf
parent11ad43675ff067cc808f79148eff4db286a9a913 (diff)
better logging
-rw-r--r--project.clj2
-rw-r--r--src/bitgloo_web/core.clj23
2 files changed, 15 insertions, 10 deletions
diff --git a/project.clj b/project.clj
index 538a8fd..9db96b3 100644
--- a/project.clj
+++ b/project.clj
@@ -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"}
diff --git a/src/bitgloo_web/core.clj b/src/bitgloo_web/core.clj
index ba34e71..bd4ba6b 100644
--- a/src/bitgloo_web/core.clj
+++ b/src/bitgloo_web/core.clj
@@ -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")))