Skip to content

Instantly share code, notes, and snippets.

@ericnormand
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericnormand/8245b1a280c7ca37f6de to your computer and use it in GitHub Desktop.
Save ericnormand/8245b1a280c7ca37f6de to your computer and use it in GitHub Desktop.
A middleware to log Ring request/response to a file.
(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