Last active
January 8, 2018 16:45
-
-
Save RishiSadhir/6574003 to your computer and use it in GitHub Desktop.
Primitive Logging System in Clojure.
This file contains hidden or 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
(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