core
core copied to clipboard
expose more debugging features, like console.group
As it stands Debug.log
is the only thing provided for instrumenting and debugging code in Elm, and it's not usable for all cases.
For example, there might be a deeply nested structure represented by the top level Model
of the application. With Debug.log
we are given an un-usable display of this complex structure as a single string without even basic indentation.
Instead lets make this kick ass. With something much more similar to the experience of logging a native javascript object to the console; where nested structures can be collapsed or expanded.
I believe this can be accomplished using console.group
, or some similar technique.
Right now it looks like the Debug.log
function simply calls toString
on the second argument (the value being logged) and appends it to the first argument. Would it be reasonable to log the value directly instead?
var msg = tag + ': ' + _elm_lang$core$Native_Utils.toString(value);
...
console.log(msg);
becomes...
console.log(tag, value);
There is kind of a lot that could be done here. I ended having to write this as a band-aid. https://gist.github.com/Fresheyeball/94e25fcefc517a74382e55283eec9093
But I wouldn't consider it a solution. I'm starting to think Elm should just expose (almost) the entirety of this: https://developer.chrome.com/devtools/docs/console-api .
And in two styles (we might want logging for things other than debugging).
Console.log : String -> Task Never ()
and for debugging in a raw way
Debug.log : String -> a -> a
This way it would be possible for Elm library authors to put together their own debugging packages.
Sounds like a cool idea! Perhaps we could start working on an elm-debug-extra
or elm-developer-console
library in order to expose more of the Console API?
No go. Elm rejects anything native. It needs to be owned by elm-lang.
I'd be happy to take this on, but @evancz would need to bless me for the task. On Mon, Jun 6, 2016 at 9:15 AM Noah Zachary Gordon [email protected] wrote:
Sounds like a cool idea! Perhaps we could start working on an elm-debug-extra or elm-developer-console library in order to expose more of the Console API?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elm-lang/core/issues/633#issuecomment-223990254, or mute the thread https://github.com/notifications/unsubscribe/AAlL_ws6r-u2VcuQY70QX4BX75TNsim7ks5qJDmugaJpZM4IqDN_ .
good idea