Hi, guys. Is there any way to get all available levels of logger?
I have checked the docs of
Logger in Elixir or
Logger in Elixir:
But didn’t find anything related to this.
I’m expecting something like:
[:emergency, :alert, ...]
Is it possible to do that? If it does, can anyone give me a tip?
Thanks in advance!
Well you can find them by doing
t :logger.level in
iex but that’s not programmatic, it’s for visual inspection only.
You can start off here: https://github.com/elixir-lang/elixir/blob/a5ac8b2b2ca5093aebfa68db857e464297d2f72c/lib/iex/lib/iex/introspection.ex#L691
And then work your way down.
…Or you can just hardcode them and map them to OTP version because I am pretty sure they don’t change within patch and minor version changes:
defmodule MyApp.Config do
26 => [:emergency, :alert, :critical, :error, :warning, :notice, :info, :debug]
Logger.levels/0 has been merged into Elixir, and will be released in v1.16.0.