Allow Logger pass functions to return associated metadata

68 views
Skip to first unread message

b...@timber.io

unread,
Nov 4, 2016, 1:35:13 PM11/4/16
to elixir-lang-core
Hi, I wanted to propose a change that allows a function passed to Logger to also return it's associated metadata.

For example, functions passed to Logger are only allowed to return a string:

Logger.debug fn -> "my log message" end

I'm proposing:

Logger.debug fn -> {"my log message", [meta: "data"]} end

This way if people take advantage of compile time purging, any code generating metadata is also removed.

Is there any reason this would not be a good idea?

Thanks!

Onorio Catenacci

unread,
Nov 4, 2016, 3:19:21 PM11/4/16
to elixir-lang-core
What's the metadata that you'd want to include that can't be interpolated into the string?

--
Onorio

b...@timber.io

unread,
Nov 4, 2016, 3:31:59 PM11/4/16
to elixir-lang-core
A variety of data (outgoing http requests, database queries, etc). We're attempting to structure all our log data. It's more about respecting the `Logger.log/3` signature so that Logger backends can do what they please with the metadata. Forcing the function to return a string limits that capabilities if we want to use compile time purging.

José Valim

unread,
Nov 5, 2016, 5:39:00 AM11/5/16
to elixir-l...@googlegroups.com
A pull request that allows the metadata to be retrieve by the function would be accepted.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
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-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/d75aeb6e-54fd-4445-b4b6-b834c27d16a9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

b...@timber.io

unread,
Nov 14, 2016, 10:46:19 AM11/14/16
to elixir-lang-core, jose....@plataformatec.com.br
Awesome, sounds great.


On Saturday, November 5, 2016 at 4:39:00 AM UTC-5, José Valim wrote:
A pull request that allows the metadata to be retrieve by the function would be accepted.



José Valim
Skype: jv.ptec
Founder and Director of R&D

On Fri, Nov 4, 2016 at 8:31 PM, <b...@timber.io> wrote:
A variety of data (outgoing http requests, database queries, etc). We're attempting to structure all our log data. It's more about respecting the `Logger.log/3` signature so that Logger backends can do what they please with the metadata. Forcing the function to return a string limits that capabilities if we want to use compile time purging.


On Friday, November 4, 2016 at 12:35:13 PM UTC-5, b...@timber.io wrote:
Hi, I wanted to propose a change that allows a function passed to Logger to also return it's associated metadata.

For example, functions passed to Logger are only allowed to return a string:

Logger.debug fn -> "my log message" end

I'm proposing:

Logger.debug fn -> {"my log message", [meta: "data"]} end

This way if people take advantage of compile time purging, any code generating metadata is also removed.

Is there any reason this would not be a good idea?

Thanks!

--
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.
Reply all
Reply to author
Forward
0 new messages