Fork me on GitHub
Leonid Scott16:01:46

Has anyone ever had issues with logging maps in a browser console? If I try to log something like this: (.log js/console "my print" {:a "here" :b true}) I get something like this:

my print {meta: null, cnt: 2, arr: Array(4), __hash: null, cljs$lang$protocol_mask$partition0$: 16647951, …}
meta: null
cnt: 2
arr: Array(4)
0: {ns: null, name: "a", fqn: "a", _hash: -2123407586, cljs$lang$protocol_mask$partition0$: 2153775105, …}
1: "here"
2: {ns: null, name: "b", fqn: "b", _hash: 1482224470, cljs$lang$protocol_mask$partition0$: 2153775105, …}
3: true
length: 4
__proto__: Array(0)
__hash: null
cljs$lang$protocol_mask$partition0$: 16647951
cljs$lang$protocol_mask$partition1$: 139268
__proto__: Object


even works for multiple args:

cljs.user=> (prn "my print" {:a 1 :b 2})
"my print" {:a 1, :b 2}

Leonid Scott16:01:16

Yeah, that works

Roman Liutikov16:01:52

Take a look at cljs-devtools

Roman Liutikov16:01:57

If you are using Figwheel for development, the devtools should be already included

Leonid Scott16:01:59

We are using shadow cljs. It’s odd because everyone else on my team using this repo has had no issues with this.

Duck Nebuchadnezzar16:01:28

make sure "enable custom formatters" is checked in your devtools section under console

Leonid Scott17:01:13

Wonderful, that fixed it! Thank you!

👍 4

@scot0530 I found wrapping all the params to (.log js/console ...) inside (str ...) takes care of that, but clunky. A good reason to (enable-console-print!) to get access to (prn ...) which doesn’t need the extra call.

Leonid Scott17:01:27

That is good to know!


Yes, just note that this returns an opaque string vs cljs-devtools' "interactive" output (i.e. like regular console.log maps)

Duck Nebuchadnezzar16:01:11

I use a lot of timbre/spy