Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 618A677AA for ; Thu, 6 Oct 2011 22:39:48 +0000 (UTC) Received: (qmail 3707 invoked by uid 500); 6 Oct 2011 22:39:45 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 3657 invoked by uid 500); 6 Oct 2011 22:39:45 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 3612 invoked by uid 99); 6 Oct 2011 22:39:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 22:39:45 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 22:39:37 +0000 Received: by vws10 with SMTP id 10so4204168vws.11 for ; Thu, 06 Oct 2011 15:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ZyhUtiCOKHV5KhAvuC4CP9et9AXtpEDFkhVyHiJQvo8=; b=h4EXaUHAiWrgGDHunFSkRFBIRkdzyIpJSHG57yatSgjf2S9q8NjA4QI+Zh2fFrSugj YOe/RiMo1N13kWr/nGd+R1wNX525NIQWJ3iaGX+nHX7jD/rmFDOcKFoNoz8cSlgpU4ps 8CcaulCkn1VjTZqv7ezwgbvPeDGfBCasfVWPw= Received: by 10.52.69.67 with SMTP id c3mr80827vdu.106.1317940757105; Thu, 06 Oct 2011 15:39:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.160.130 with HTTP; Thu, 6 Oct 2011 15:38:37 -0700 (PDT) In-Reply-To: References: From: Paul Davis Date: Thu, 6 Oct 2011 17:38:37 -0500 Message-ID: Subject: Re: [Erlang] Logging To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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 wrote: > Hi, > > Is there a way to log from within an Erlang view? I am trying to reproduc= e > 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 =3D fun({Row}, _) -> > Val =3D couch_util:get_value(<<"value">>, Row, -1), > Send(list_to_binary(integer_to_list(Val))), > {ok, nil} > end, > {ok, _} =3D FoldRows(Fun, nil), > <<"tail">> > end. > > Error: > > [Thu, 06 Oct 2011 22:27:53 GMT] [info] [<0.7216.1>] Stacktrace: > [{erlang,list_to_binary, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[[{'EX= IT', > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= {case_clause, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 {'EXIT', > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0{badarg, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 [{erlang,integer_to_list, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 [<<"str1">>]}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0{erl_eval,do_apply,5}, >