Last active
August 29, 2015 14:02
-
-
Save ericnormand/8245b1a280c7ca37f6de to your computer and use it in GitHub Desktop.
A middleware to log Ring request/response to a file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def logger (agent nil)) | |
(def logfile (java.io.FileWriter. "output.edn")) | |
(defn log [a x] | |
(binding [*out* logfile | |
*print-length* 200] | |
(prn x))) | |
(defn wrap-logging [hdlr] | |
(fn [req] | |
(let [resp (hdlr req)] | |
(send-off logger {:request req :response resp}) | |
resp))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment