From 26f7ef04351554f78280ed2842ef7a65bf6c12ce Mon Sep 17 00:00:00 2001 From: Vasu Adari Date: Tue, 14 Mar 2023 10:54:31 +0530 Subject: [PATCH] add debug_log option to disable debug logs by default --- .tool-versions | 2 +- lib/flume/config.ex | 1 + lib/flume/default_logger.ex | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.tool-versions b/.tool-versions index 68f07a4..f72829c 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.6.6 +elixir 1.8.2 erlang 21.3 diff --git a/lib/flume/config.ex b/lib/flume/config.ex index d089fd3..0025366 100644 --- a/lib/flume/config.ex +++ b/lib/flume/config.ex @@ -18,6 +18,7 @@ defmodule Flume.Config do dequeue_lock_ttl: 30_000, dequeue_process_timeout: 10_000, dequeue_lock_poll_interval: 500, + debug_log: false, # In seconds visibility_timeout: 600, instrumentation: [ diff --git a/lib/flume/default_logger.ex b/lib/flume/default_logger.ex index 7acf07f..8a6c29e 100644 --- a/lib/flume/default_logger.ex +++ b/lib/flume/default_logger.ex @@ -3,8 +3,13 @@ defmodule Flume.DefaultLogger do require Logger - def debug(message, %{}), do: Logger.debug(message) - def debug(message, opts), do: Logger.debug("#{message} - #{inspect(opts)}") + def debug(message, %{}) do + if Flume.Config.debug_log(), do: Logger.debug(message) + end + + def debug(message, opts) do + if Flume.Config.debug_log(), do: Logger.debug("#{message} - #{inspect(opts)}") + end def error(message, %{}), do: Logger.error(message) def error(message, opts), do: Logger.error("#{message} - #{inspect(opts)}")