Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of debug messages from libraries in Elixir script?

Tags:

logging

elixir

I have a script which uses some libraries which seem to be running Logger in debug mode. First lines of my script:

#!/usr/bin/env -S ERL_FLAGS=+B elixir
Mix.install([{:req, "~> 0.5.0"},{:feeder_ex, "~> 1.1.0"},{:timex, "~> 3.7.0"},{:yaml_elixir, "~> 2.9"}])

One of the messages I get looks like this:

enter image description here

I get similar messages for example from Req when a redirect happens...

How can I get rid of all these messages?

like image 894
TNT Avatar asked Oct 30 '25 15:10

TNT


1 Answers

Put this in the second line of your script (after the first line where you specify to run it with elixir).

Logger.configure([level: :warning])

This will only show :warning logs and higher (e.g. :error).

Maybe you would prefer :info level.

More info here: https://hexdocs.pm/logger/1.12.3/Logger.html#module-runtime-configuration

If you ever use iex then it is also possible to configure logger by adding that line to your .iex.exs file (it usually lives in the project directory or in your home directory or both).

like image 121
Peaceful James Avatar answered Nov 01 '25 05:11

Peaceful James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!