dynamic var | since v1.7.10 | Edit |
A var representing the function used to print error output, which may differ
between runtime environments. Use enable-console-print!
to
set it to print to console/stderr, then bind as follows:
(enable-console-print!)
(binding [*print-fn* *print-err-fn*]
(println "printed to stderr in Node, or to browser console as error"))
This is meant to replace a use-case of Clojure's *err*
var,
allowing you to print things to stderr using the print function.
;; Clojure
(binding [*out* *err]
(println "error"))
;; ClojureScript
(binding [*print-fn* *print-err-fn*]
(println "error"))
Each runtime environment provides a different way to print error output. Whatever function *print-err-fn* is bound to will be passed any Strings which should be printed.
(defonce
^{:dynamic true}
*print-err-fn* nil)