On Friday, 31 October 2014 21:05:18 UTC, Marcus Lewis wrote:
> Currently, with ClojureScript logging, you have to choose between:
>
> a. Correct newlines in browser console, but no newlines in the REPL (very
> ugly)
> b. Extra newlines in the browser console, and correct REPL
>
>
> If you want Option A, set *print-newline* false. If you want Option B, set
> *print-newline* true. You can see this with a "lein new chestnut" project --
> it chooses Option A via enable-console-print!.
>
>
> Is there a chance we can ever get the best of both worlds? I don't think this
> is possible with the current *print-fn* approach. Strings are passed to the
> *print-fn* without information about whether a newline is intended. So I
> think fixing this would either require passing this information, or allowing
> multiple [*print-fn* *print-newline*] tuples to be set.
>
>
> (Let me know if I've overlooked something)
I ran into this issue today and came across this post while googling for an
alternative. I ended up writing this function, which seems to work pretty well
when *print-newline* is left as true.
```
;; printing goes to browser console
(let [c js/console
log (.-log c)]
(set-print-fn!
(fn [& args]
(let [args (if (= (last args) "\n") (butlast args) args)]
(.apply log c (into-array args))))))
```
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.