binaryage / cljs-devtools

A collection of Chrome DevTools enhancements for ClojureScript developers
Other
1.11k stars 51 forks source link

Should (prn my-map) be doing a pretty print in console? mine doesn't... #58

Open mikew1 opened 3 years ago

mikew1 commented 3 years ago

Hi, I have cljs-devtools installed, I get the notification in the console that :formatters is active, and I sometimes see colored, formatted clojure data structures, but I was hoping that when I do (prn my-map) within some cljs source file, that would justify and color a large map. I'm just getting a regular print of the datastructure in the console, same as when cljs-devtools is not active. Am I doing something wrong? Thanks.

mikew1 commented 3 years ago

Apologies, it was my lack of experience with cljs that was the issue here. Once I realised that studying the code in the screenshot on the docs page is absolutely crucial, I got it fine. My error was to be using prn instead of console.log (prn does print to the console after all!), but for the formatters to work, it seems it's essential to use .log js/console and not prn/println.

The only way I found this out was by carefully studying the code in the screenshot, as this isn't pointed out in the main text of the docs anywhere...

Would you like a pull request on the FAQ page adding a couple of lines to make it clear, (in the main markdown text), what exactly is being shown in the screenshot? This might reduce an occasional beginner's head scratching.