Skip to content

Instantly share code, notes, and snippets.

@darwin
Created February 19, 2017 13:23
Show Gist options
  • Save darwin/6b229ece516861ebfb97f4daa28b9869 to your computer and use it in GitHub Desktop.
Save darwin/6b229ece516861ebfb97f4daa28b9869 to your computer and use it in GitHub Desktop.
(defn log [logger level fmt-msg & objs]
(let [msg-obj (js/String. fmt-msg)]
(aset msg-obj "fmt-objs" objs)
(.log logger level msg-obj)))
(defn handler [log-record]
(let [msg-obj (.getMessage log-record)
objs (aget msg-obj "fmt-objs")
log-fn (.-log js/console)]
(.apply log-fn js/console msg-obj (to-array objs))))
(goog-log/addHandler logger handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment