erlang – 在Elixir伞应用程序中,应该将logger后端应用程序添加为依赖项?

我有一个Elixir伞形应用程序.伞下的应用程序使用 Logger.我想为:logger应用程序添加后端( logger_logstash_backend).所以,我需要在混合文件添加它作为deps函数的依赖项.

在伞形应用程序的最外层混合文件中,deps函数的文档说明:

Dependencies listed here are available only for this project
and cannot be accessed from applications inside the apps folder

这意味着我必须将后端模块添加为伞下每个应用程序的依赖项.但是,这样做会导致几个问题:

>以后将单个应用程序移出单独的库变得更加困难.
>伞下的各个应用程序实际上并不依赖于自定义:记录器后端模块.认情况下它们没问题:控制台后端.但我想只为prod环境增加一个后端.因此,更多的是跨应用程序问题,我不得不单独向每个应用程序添加依赖项.

你知道更好的策略吗?它是什么?

每个应用程序都应该有自己的依赖项和配置.

你提到的问题:

  1. It becomes harder to move out the individual applications as separate
    libraries later.

如果您在每个应用程序中都有配置,这实际上可以更轻松地将各个应用程序移出伞形应用程序.如Elixir guides中所述,您只需将应用程序移出apps /目录即可.

  1. The individual applications under the umbrella are not actually dependent on the custom :logger backend module. They’re okay with default :console backend. But I want to have an additional backend only for prod environment. Therefore,it’s more of a cross-applications concern where I’m forced to add the dependency to each application individually.

如果仅在生产环境中需要自定义记录器后端,则应用程序只能将此配置添加到config / prod.exs文件中,并仅在prod环境中使用此配置.

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...