I’m building an umbrella app, and all apps use Logger module: Phoenix uses :info, but in other app (facebook.ex) :info is too verbose. Is there a way to use Logger with different levels? Or there is only one level for the entire umbrella app?
I think the only way you would achieve this is to use a custom backend, and then use the
:module metadata keys to do something with it.
Backends like https://github.com/onkel-dirtus/logger_file_backend has a
metadata_filter config option that you can use to filter out messages to certain files.
Alternatively if you want it in a console, it shouldn’t be that hard to knock up what you need:
- Copied the main Logger.Backend.Console from https://github.com/elixir-lang/elixir/blob/master/lib/logger/lib/logger/backends/console.ex
- Added some metadata filtering from https://github.com/onkel-dirtus/logger_file_backend/blob/master/lib/logger_file_backend.ex
Ended up with https://gist.github.com/benperiton/94a02edeef7684c4b3bd6422e4b10118
Quick and dirty, but might do what you need.
Thank you! That should fix it