[erlang-questions] lager/io:format and sets
Tue Nov 11 09:33:40 CET 2014
I would not recommend to change the internal representation just for making pretty printing simpler.
I'd either make a private conversion function, or if this concerns an otp genserver implement the gen_server optional behaviour format_status/2.
You'd have to do the conversion of the State yourself, and then call the function every time you want to log the state.
The advantage of making the conversion in the format_status/2 function is that also crash reports will contain converted state.
Perhaps also in other tools too, like observer, I haven't tried.
From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Cian Synnott
Sent: den 11 november 2014 02:14
To: Oleg Tsarev
Subject: Re: [erlang-questions] lager/io:format and sets
>On Tue, Nov 11, 2014 at 12:02 AM, Oleg Tsarev <oleg@REDACTED> wrote:
>> How I can fix the output of the set in lager and io:format?
>I don't see a "built in" way to fix this. To roll your own, you could "patch over" the record with sets:to_list/1 to make a printable version. E.g. something like
>lager:debug("args ~p, state ~p", [Args, lager:pr(printable(State), ?MODULE)),
>It's not super. You might need to change the record's type annotations to avoid upsetting Dialyzer.
More information about the erlang-questions