aquarhead

aquarhead

Why is `:logger` included in extra_applications by default?

Many projects never remove it even though they don’t use Logger at all. I myself always clean out all comments and skeleton code as well as :logger as soon as I generate a new project, unless I intend to use it very soon. But I have seen so many open source projects just leave it there, from my friends’ projects to widely adopted packages to even community standard tools.

While normally this is not a problem for “pure” Elixir projects, it can be tricky when Erlang dependencies are involved. E.g. :lager used to play badly together with Logger, though this situation seems to be well resolved now. My actual problem arose because ejabberd works around this issue by dropping :lager in favor of Logger, but we depend on :lager’s file backend to ship logs around. I spent a good part of yesterday just to remove :logger from the extra_applications list of all my dependencies - none of them use Logger. (couldn’t find an obvious way to just remove :logger when building release w/ distillery)

It also doesn’t feel quite clean to have unused dependencies just laying around.

I would like to know what’s reason behind having it by default in newly generated projects? Is there some deep technical reasons? Or is it just to prevent people mistakenly require Logger without starting it up first?

If there’s a better way to solve my case I would like to know as well.

Thanks ahead!

Most Liked

bitwalker

bitwalker

Leader

In Distillery’s case, it used to use Logger, but later shifted to using its own implementation for shell output - it was just never removed from the applications list.

In general I suspect it is there, as you pointed out, to prevent confusion with using Logger when it is not started. This same problem happened all the time with Timex when people would not add it to their applications list, and then call an API which required timezone data (using tzdata which would blow up when not started), so I definitely understand the motivation.

As for projects not playing nicely with Logger, I believe this can be solved with configuration, particularly for use cases like yours by using something like logger_lager_backend. You could also run both Logger and lager side-by-side by configuring Logger not to handle OTP/SASL reports, since I think that is the primary place where conflict is likely to happen. With the new logger module in Erlang’s standard library, I think conflicts between logging libraries will be even less likely, since they will share the same underlying infrastructure, at least as I understand it.

In any case, I’m not advocating for one side or the other, I can see reasons why it is good to include Logger by default, and reasons why maybe it isn’t such a good idea. Ultimately it is still up the library maintainers to “do the right thing”. If a library does depend on Logger, which is common enough, you’ll need to have a strategy to deal with it anyway, so I don’t see changing the default for Elixir projects as really solving the problem you’ve stated.

dimitarvp

dimitarvp

Requiring the programmers to include an app in the extra_applications list is not rocket science. Not sure what they get confused about, every project on GitHub that needs you to do that is clearly communicating it in their README as far as I have seen so far. Every language and platform has specifics. We are paid to be good at delivering working code, and knowing your tools is an intrinsic part of that.

However, if there are projects that would make use of Logger if it exists in the dependencies and fall back to something else if it doesn’t… that might introduce WTFs indeed.

I see both sides’ arguments but IMO the minimalistic approach should be the default.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement