Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace get_env with compile_env in module body & minor enhancement with version upgrade. #580

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/tesla/middleware/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ defmodule Tesla.Middleware.Logger do

alias Tesla.Middleware.Logger.Formatter

@config Application.get_env(:tesla, __MODULE__, [])
@config Application.compile_env(:tesla, __MODULE__, [])

@format Formatter.compile(@config[:format])

@type log_level :: :info | :warn | :error
Expand Down
7 changes: 3 additions & 4 deletions lib/tesla/middleware/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ if Code.ensure_loaded?(:telemetry) do
```
"""

@disable_legacy_event Application.get_env(:tesla, Tesla.Middleware.Telemetry,
disable_legacy_event: false
)[:disable_legacy_event]
@disable_legacy_event Application.compile_env(:tesla, Tesla.Middleware.Telemetry,
disable_legacy_event: false)[:disable_legacy_event]
Comment on lines +83 to +84
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@disable_legacy_event Application.compile_env(:tesla, Tesla.Middleware.Telemetry,
disable_legacy_event: false)[:disable_legacy_event]
@disable_legacy_event Application.compile_env(:tesla [Tesla.Middleware.Telemetry, :disable_legacy_event], false)

I think this is a clearer implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. Thanks for enhancement.


@behaviour Tesla.Middleware

Expand Down Expand Up @@ -142,7 +141,7 @@ if Code.ensure_loaded?(:telemetry) do
end

if @disable_legacy_event do
defp emit_legacy_event(duration, result) do
defp emit_legacy_event(_duration, _result) do
:ok
end
else
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ defmodule Tesla.Mixfile do
use Mix.Project

@source_url "https://github.com/teamon/tesla"
@version "1.6.1"
@version "1.7.0"

def project do
[
app: :tesla,
version: @version,
description: description(),
package: package(),
elixir: "~> 1.7",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps(),
lockfile: lockfile(System.get_env("LOCKFILE")),
Expand Down