Add dynamic :stream opts to core println appender

This commit is contained in:
Peter Taoussanis 2015-05-29 12:01:17 +07:00
parent fc56b8f86d
commit 4748743dd1
1 changed files with 5 additions and 3 deletions

View File

@ -71,7 +71,7 @@
"Returns a simple `println` appender for Clojure/Script.
Use with ClojureScript requires that `cljs.core/*print-fn*` be set.
:stream (clj only) - e/o #{:auto :std-err :std-out <io-stream>}."
:stream (clj only) - e/o #{:auto :*out* :*err* :std-err :std-out <io-stream>}."
;; Unfortunately no easy way to check if *print-fn* is set. Metadata on the
;; default throwing fn would be nice...
@ -93,8 +93,10 @@
(let [{:keys [output-fn]} data]
#+cljs (println (output-fn data))
#+clj
(let [stream (if (= stream :auto)
(if (:error? data) *err* *out*)
(let [stream (case stream
:auto (if (:error? data) *err* *out*)
:*out* *out*
:*err* *err*
stream)]
(binding [*out* stream] (println (output-fn data))))))}))