Skip to content

Instantly share code, notes, and snippets.

@RishiSadhir
Last active January 8, 2018 16:45
Show Gist options
  • Save RishiSadhir/6574003 to your computer and use it in GitHub Desktop.
Save RishiSadhir/6574003 to your computer and use it in GitHub Desktop.
Primitive Logging System in Clojure.
(defn print-logger
[writer]
#(binding [*out* writer]
(println %)))
(defn file-logger
[file]
#(with-open [f (clojure.java.io/writer file :append true)]
((print-logger f) %)))
;; Usage
(def log (file-logger "/tmp/log"))
(log "hi")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment