Skip to content

Commit 937241b

Browse files
committed
Replace get_env with compile_env in module body
1 parent 30c3a29 commit 937241b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/tesla/middleware/logger.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ defmodule Tesla.Middleware.Logger do
182182

183183
alias Tesla.Middleware.Logger.Formatter
184184

185-
@config Application.get_env(:tesla, __MODULE__, [])
185+
@config if function_exported?(Application, :compile_env, 3),
186+
do: Application.compile_env(:tesla, __MODULE__, []), else:
187+
Application.get_env(:tesla, __MODULE__, [])
188+
186189
@format Formatter.compile(@config[:format])
187190

188191
@type log_level :: :info | :warn | :error

lib/tesla/middleware/telemetry.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ if Code.ensure_loaded?(:telemetry) do
8080
```
8181
"""
8282

83-
@disable_legacy_event Application.get_env(:tesla, Tesla.Middleware.Telemetry,
84-
disable_legacy_event: false
85-
)[:disable_legacy_event]
83+
@disable_legacy_event (if function_exported?(Application, :compile_env, 3),
84+
do: Application.compile_env(:tesla, __MODULE__), else:
85+
Application.get_env(:tesla, __MODULE__, []))[:disable_legacy_event] || false
86+
8687

8788
@behaviour Tesla.Middleware
8889

0 commit comments

Comments
 (0)