Maps and merge behaviour in Config

61 views
Skip to first unread message

lostko...@gmail.com

unread,
Mar 30, 2023, 6:07:59 AM3/30/23
to elixir-lang-core
We'll be seeing deeper integration with :logger in the upcoming elixir version, but :logger is using maps for configuration, which don't merge in config, but require changing the whole map for any small change within the map. Afaik maps are meant to become more common for configuration on erlangs end, so are there any plans to bring the merging behaviour of keyword lists to maps as well?

José Valim

unread,
Mar 30, 2023, 6:34:54 AM3/30/23
to elixir-l...@googlegroups.com
Can you please provide examples of where this may happen?

On Thu, Mar 30, 2023 at 12:08 PM lostko...@gmail.com <lostko...@gmail.com> wrote:
We'll be seeing deeper integration with :logger in the upcoming elixir version, but :logger is using maps for configuration, which don't merge in config, but require changing the whole map for any small change within the map. Afaik maps are meant to become more common for configuration on erlangs end, so are there any plans to bring the merging behaviour of keyword lists to maps as well?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/754c06e5-62e2-48b1-a58b-7292afb34097n%40googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted

lostko...@gmail.com

unread,
Apr 28, 2023, 9:01:51 AM4/28/23
to elixir-lang-core
Trying this again as my last 3 answers got deleted:

For example here:

config :logger, :default_handler,  config: %{
    file: ~c"system.log",
    filesync_repeat_interval: 5000,
    file_check: 5000,
    max_no_bytes: 10_000_000,
    max_no_files: 5
  }

... as described in https://hexdocs.pm/logger/main/Logger.html#module-boot-configuration

Say I want to change the file path for different envs.

José Valim

unread,
Apr 28, 2023, 10:19:35 AM4/28/23
to elixir-l...@googlegroups.com
I am wondering if we should allow keyword lists in those cases instead but it can be confusing if folks then use the direct Erlang APIs.

Christopher Keele

unread,
Apr 28, 2023, 6:43:55 PM4/28/23
to elixir-lang-core
I can second that this has caught me off-guard before as well, and keyword list support would be a welcome addition.

> It can be confusing if folks then use the direct Erlang APIs.

I think this could be circumvented for now by only describing the proposed keyword list support in the boot configuration documentation (https://hexdocs.pm/logger/main/Logger.html#module-boot-configuration), and being consistent elsewhere throughout documentation and project scaffolds with whatever the Erlang API is. This suggests a series of deprecation warnings between when Elixir adopts an OTP that supports maps for logger configuration, and the last release in which support for OTP releases that only use keyword lists is realized.

José Valim

unread,
Apr 28, 2023, 6:52:55 PM4/28/23
to elixir-l...@googlegroups.com
A PR for supporting keywords on the default handler is welcome. :)

Reply all
Reply to author
Forward
0 new messages