Skip to content

Commit

Permalink
Replace get_env with compile_env in module body
Browse files Browse the repository at this point in the history
  • Loading branch information
uzairaslam196 committed May 12, 2023
1 parent 30c3a29 commit 937241b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/tesla/middleware/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ defmodule Tesla.Middleware.Logger do

alias Tesla.Middleware.Logger.Formatter

@config Application.get_env(:tesla, __MODULE__, [])
@config if function_exported?(Application, :compile_env, 3),
do: Application.compile_env(:tesla, __MODULE__, []), else:
Application.get_env(:tesla, __MODULE__, [])

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

@type log_level :: :info | :warn | :error
Expand Down
7 changes: 4 additions & 3 deletions lib/tesla/middleware/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ 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 (if function_exported?(Application, :compile_env, 3),
do: Application.compile_env(:tesla, __MODULE__), else:
Application.get_env(:tesla, __MODULE__, []))[:disable_legacy_event] || false


@behaviour Tesla.Middleware

Expand Down

0 comments on commit 937241b

Please sign in to comment.