-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: String with metadata mode #57
Comments
Perhaps this could result in a better |
I had no time to look into this yet. I believe you could achieve something similar with Try something like this (from top of my head): (specify! (js/String. (pr-str data)) IMeta (-meta [_] data))))) |
That partially solves the "string with metadata" issue. cljs.user=>
(defn data-str [data]
(binding [*print-level* 3 *print-length* 5]
(specify! (js/String. (pr-str data)) IMeta (-meta [_] data))))
cljs.user=> (data-str {:a (range 10)})
#object[String {:a (0 1 2 3 4 ...)}]
cljs.user=> (meta (data-str {:a (range 10)}))
{:a (0 1 2 3 4 5 6 7 8 9)} But the console output associated with String objects isn't what we were hoping for... Test: Just Test: Just Test: Just Test: Just |
This is the best I've come up with (defn log-data [& data]
(binding [*print-level* 3 *print-length* 5]
(let [s (apply pr-str data)
d (specify! #js [] IMeta (-meta [_] data))]
(js/console.log s d))))
(log-data :this {:is "a" :test (range 100)}) It looks fine from a metro bundler terminal.
I suspect cljs-devtools could be made to handle the "array with meta" better. Still a bit ugly from console without devtools... |
This is a feature idea.
I'm looking for a way to make my js/console.log display cleanly with and without cljs-devtools installed.
Motivating example
Today's job is a react native app. It's not always convenient to turn cljs-devtools on (e.g. two simulators) and it's helpful to look in the simulator logs sometimes (no cljs-devtool rendering).
Problems
Idea
Perhaps cljs-devtools could be adapted to look for metadata associated with a string (or string like) object.
Vaguely something like this could be used to prepare a "console.log friendly string" with some other protocol which cljs-devtools could detect...
NOTE: this code doesn't work
Goal is to cover two cases
The text was updated successfully, but these errors were encountered: