Hello,

I want to write a simple logging-wrapper around console.log, with the
background of being able to enable/disable logging at any time. This is
my current implementation:

--8<---------------cut here---------------start------------->8---
(defn log [& more]
  (.log js/console (apply pr-str more)))
--8<---------------cut here---------------end--------------->8---

This particuliar implementation is pretty nice (and awfully slow) for
Clojure data structures. It's unusablw for raw javascript data like
HTMLElements and other Objects with no reasonable implementation of
pr-str.

I want to print "raw" javascript objects using console.log and clojure
data using pr-str.

Doing this sort of switch should be easy, where I'm stuck is running
apply on console.log. I want to do something like:

--8<---------------cut here---------------start------------->8---
(apply (.-log js/console) (map ... args))
--8<---------------cut here---------------end--------------->8---

Which doesn't work. (I guess because console.log doesn't feature .call)

Can anyone point me in the right direction?


Cheers,

--
Moritz Ulrich

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to