[Proposal] Logger should be able to put information even in case of pid or ref

29 views
Skip to first unread message

Susumu YAMAZAKI

unread,
May 28, 2020, 5:23:44 PM5/28/20
to elixir-lang-core
Hi,

Elixir 1.11 will enable Logger put information of a struct. However, pid, ref and so on are except.

Of course, I know this can be avoided by implementing String.Chars protocol, like https://devbrett.com/2018/08/implement-string-protocol-elixir-pid.html

Why don't pid and ref have a definition of default String.Chars protocol? Or, I think Logger should be able to put information even in case of pid or ref, that is, even in case that String.Chars protocol for it isn't defined.

Especially, when we develop industrial IoTs using Nerves, logging pid or ref is often used. Thus, the lack of the function that I proposed makes programmers be troubled with the issue.

José Valim

unread,
May 28, 2020, 5:35:32 PM5/28/20
to elixir-l...@googlegroups.com
The string protocol must be used only for things that have natural human representations, such as numbers, dates.

I believe a more reasonable case would be to use inspect instead of to_string.

Susumu YAMAZAKI

unread,
May 29, 2020, 4:17:48 AM5/29/20
to elixir-l...@googlegroups.com
Thank you for your reply, Jose.

I'll read documents on string protocol, carefully. 

Why doesn't Logger inspect by default?

On Fri, May 29, 2020 at 6:35 AM José Valim <jose....@dashbit.co> wrote:
The string protocol must be used only for things that have natural human representations, such as numbers, dates.

I believe a more reasonable case would be to use inspect instead of to_string.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KSXkSr8JGS4wwYsx8jtA171CYFBqTSRhw4LHoiKcXeBA%40mail.gmail.com.


--
山崎 進(Susumu YAMAZAKI)

Susumu YAMAZAKI

unread,
May 29, 2020, 4:47:11 AM5/29/20
to elixir-l...@googlegroups.com
Hi, Jose, all

I found too short to understand such backgrounds and principles:


I recommend to describe such intention to this official document.


--
山崎 進(Susumu YAMAZAKI)

Susumu YAMAZAKI

unread,
May 29, 2020, 5:46:53 AM5/29/20
to elixir-l...@googlegroups.com
In addition,

If there are previous discussions on ML and/or GitHub, would you please point them out to me?

I and Prof. Yutaka Kikuchi, who is a collaborator of ElixirConf JP, will make a PR to the document.
--
山崎 進(Susumu YAMAZAKI)

José Valim

unread,
May 29, 2020, 5:48:15 AM5/29/20
to elixir-l...@googlegroups.com
We could change it to use inspect, I don't think it is a major problem. Or we could special case PIDs and REFs to be included - I would probably prefer that. What is the metadata that you are trying to include here?

Reply all
Reply to author
Forward
0 new messages