Its not the prettiest, but you can do this:

Log(lists:flatten(io_lib:format("~p", [Val])))


On Thu, Oct 6, 2011 at 5:34 PM, Thomas Van de Velde
<thomase...@gmail.com> wrote:
> Hi,
>
> Is there a way to log from within an Erlang view? I am trying to reproduce
> the unit test for the list function and am getting an error. I'd like to log
> the value of "Val" so I can understand the underlying data structure. I
> tried error_logger:info_report(Val). Thanks!
>
> Output from view:
>
> {"total_rows": 1,"offset": 0,"rows": [{"id": "1","key": 1,"value": "str1"}]}
>
> List code:
>
> fun(Head, {Req}) ->
> Send(<<"head">>),
> Fun = fun({Row}, _) ->
> Val = couch_util:get_value(<<"value">>, Row, -1),
> Send(list_to_binary(integer_to_list(Val))),
> {ok, nil}
> end,
> {ok, _} = FoldRows(Fun, nil),
> <<"tail">>
> end.
>
> Error:
>
> [Thu, 06 Oct 2011 22:27:53 GMT] [info] [<0.7216.1>] Stacktrace:
> [{erlang,list_to_binary,
>                                  [[{'EXIT',
>                                     {{case_clause,
>                                       {'EXIT',
>                                        {badarg,
>                                         [{erlang,integer_to_list,
>                                           [<<"str1">>]},
>                                          {erl_eval,do_apply,5},
>

Reply via email to