Should Debug.log log JS value when applicable?


#1

Debug.log, as it stands, just logs your tag and a string representation of whatever argument you pass it. This works fine for a lot of debugging, but when logging nested structures, getting a one-line string instead of the browsers built-in representation can make for some tedious debugging sessions.

Would it be a good idea to change the output of Debug.log to output a JS object in some cases? Or maybe even add a separate Debug-function that always outputs the JS value? Maybe keeping strings but pretty printing them should be an option?


#2

I actually started experimenting with this as I also found the output from Debug.log hard to read sometimes:

Debug.log
    "testing"
    { tuple2 = ("first", "second")
    , tuple3 = ("first", "second", "third")
    , set = ["one", "two", "three"] |> Set.fromList
    , number = 123.123
    , string = "some string"
    , bool = True
    , list = [1, 2, 3, 4]
    , dict = Dict.fromList
        [ ( "key1", "val1" )
        , ( "key2", "val2" )
        ]
    }