I have a worker which creates database queries, like that:
defmodule MyApp.Periodically do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
schedule_work() # Schedule work to be performed at some point
{:ok, state}
end
def handle_info(:work, state) do
# big amount of ecto stuff
schedule_work() # Reschedule once more
{:noreply, state}
end
defp schedule_work() do
Process.send_after(self(), :work, 2 * 60 * 60 * 1000) # In 2 hours
end
end
Everything is fine except one thing. When I'm opening iex -S mix
I receive a lot of ecto debug messages into my shell, like:
01:58:10.921 [debug] QUERY OK db=7.8ms decode=0.2ms
SELECT r0."id", r0."description", r0."property_type", r0."beds", r0."baths", r0."square", r0."price", r0."availability", r0."state", r0."country", r0."city", r0."address", r0."zipcode", r0."full_address", r0."external_provider_url", r0."location", r0."visits_count", r0."likes_count", r0."comments_count", r0."deleted_at", r0."credits", r0."somehere", r0."zis", r0."thumbnail_type", r0."video", r0."review_thumbnail", r0."user_id", r0."inserted_at", r0."updated_at" FROM "reviews" AS r0 WHERE (r0."zis" IS NULL AND r0."somehere" IS NULL) ORDER BY r0."id" LIMIT 1 []
How can I avoid that?
You can either change your log level (in iex):
Logger.configure(level: :info)
Or in your config:
config :logger, level: :info
You can disable Ecto's logs entirely with:
config :my_app, MyApp.Repo,
loggers: []
As described in https://hexdocs.pm/ecto/Ecto.Repo.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With