View Source Credo.Check.Warning.LazyLogging (Credo v1.7.0)

This check has a base priority of high and requires Elixir < 1.7.0.

explanation

Explanation

Ensures laziness of Logger calls.

You will want to wrap expensive logger calls into a zero argument function (fn -> "string that gets logged" end).

Example:

# preferred

Logger.debug fn ->
  "This happened: #{expensive_calculation(arg1, arg2)}"
end

# NOT preferred
# the interpolation is executed whether or not the info is logged

Logger.debug "This happened: #{expensive_calculation(arg1, arg2)}"

check-specific-parameters

Check-Specific Parameters

Use the following parameters to configure this check:

ignore

:ignore

Do not raise an issue for these Logger calls.

This parameter defaults to [:error, :warn, :info].

general-parameters

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.