We have a logger use case that I think can be pretty common.

Our application emits logs with a metadata containing the application user
ID.
We need to be able to change the logger level on a per-user basis.
For instance we would have the global logger level set to notice but we
want to change it to debug for a specific user that is having problems.

Right now in our implementation we set the log level in primary logger
config to all and we install a custom filter that, based on our
configuration, applies user exceptions. This is because in general we
should be able to emit logs with any level and the only way we found to do
it is to let them all enter the handler/filter chain (global level to all)
and then apply filters afterwards.

This is working as expected but has a drawback: we have some debug logs
whose message is expensive to generate (inspect of large structures) and
with this configuration we always evaluate it (also when not actually
emitting that log) because of the primary log level set to all.

It would be nice to have some sort of hook that can allow a logger user to
apply some more complex filter on log event generation, before entering the
whole handlers/filters chain. Right now only the log level is checked
against the global one.

A more invasive alternative would be to avoid expanding the log message
(when given as a function) until the very last moment when the log should
be emitted.

Cheers,
Alberto

-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAAFKkp%2BSttiFbf7iUBnLfXuWr%3D3%3DT_asDie_vz-ym3XsvcGRyQ%40mail.gmail.com.

Reply via email to