Is there a way to suppress SQL output in custom Mix tasks?

I am making a custom mix task in a project and it’s working fine (using Repo as well).

However, I am not happy that it outputs the SQL when it works with the DB. Is there a way to silence the SQL statements?

1 Like

Could set the logger output to a higher level, warning or error or so?

I could, but that would affect the colleagues working in iex in their dev environment. Is there a way to change the log level at runtime instead of fiddling with dev.exs?

You could make a dev_silent.exs for example, or change dev.exs to set the logger level to something specified in the local environment if it exists else default to whatever it does now, then you could do something like BLAH=quiet mix whatever or so.

Nevermind, I had a very derpy moment:

Logger.configure([level: :info])

Putting this in the code of the mix task worked immediately.

Ah yeah if it is a custom mix task can just set it within it. ^.^