On the main Elixir project I work on, I’ve found that the log messages we
naturally write tend to lack sufficient context to identify where in the
application the message comes from. For example:
Logger.warn("Extra metadata lines found while only expecting one: #{inspect
rest}")
In the context of our application, there are a number of places this could
come from. When we see it in our logs, we can of course search our source
code to find where it came from, but I’ve gotten in the habit of prepending
the module to my log messages so the context is clear:
Logger.warn("#{__MODULE__}: Extra metadata lines found while only expecting
one: #{inspect rest}")
At this point, it would be simpler (and more consistent) if the module was
available in Logger metadata — then we could just configure it to *always*
be included in every log message, and not have to manually add it to each
one.
So, my proposal is for Elixir to make the module available in Logger
metadata, so folks who want it included in every log message (like us) can
configure it to do so. I’m willing to work up a PR to add support for this
if there’s a consensus reached to add it. If we do add it, we should decide
what to call the metadata key. :module is simple, but perhaps isn’t
intuitively obvious what it means. Maybe :callsite_module (or similar)
would be better? I’m not sure.
Thanks,
Myron
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/9841f8fe-9776-4d69-9874-890d0f8502d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.