@@ -337,6 +337,62 @@ defmodule Tesla.Middleware.LoggerTest do
337337
338338 assert output =~ ":log_level option is deprecated"
339339 end
340+
341+ test "log_level with atom value still works (backward compatibility)" do
342+ Logger . configure ( level: :debug )
343+
344+ warning_output =
345+ ExUnit.CaptureIO . capture_io ( :stderr , fn ->
346+ client =
347+ Tesla . client (
348+ [
349+ { Tesla.Middleware.Logger , log_level: :debug }
350+ ] ,
351+ fn env -> { :ok , % { env | status: 200 } } end
352+ )
353+
354+ log_output = capture_log ( fn -> Tesla . get ( client , "/test" ) end )
355+ assert log_output =~ "[debug] GET /test -> 200"
356+ end )
357+
358+ assert warning_output =~ ":log_level option is deprecated"
359+ end
360+
361+ test "log_level with atom value for warning levels" do
362+ warning_output =
363+ ExUnit.CaptureIO . capture_io ( :stderr , fn ->
364+ client =
365+ Tesla . client (
366+ [
367+ { Tesla.Middleware.Logger , log_level: :warn }
368+ ] ,
369+ fn env -> { :ok , % { env | status: 200 } } end
370+ )
371+
372+ log = capture_log ( fn -> Tesla . get ( client , "/test" ) end )
373+ assert log =~ "[warning] GET /test -> 200"
374+ end )
375+
376+ assert warning_output =~ ":log_level option is deprecated"
377+ end
378+
379+ test "log_level with atom value handles error responses" do
380+ warning_output =
381+ ExUnit.CaptureIO . capture_io ( :stderr , fn ->
382+ client =
383+ Tesla . client (
384+ [
385+ { Tesla.Middleware.Logger , log_level: :info }
386+ ] ,
387+ fn _env -> { :error , :connection_failed } end
388+ )
389+
390+ log = capture_log ( fn -> Tesla . get ( client , "/test" ) end )
391+ assert log =~ "[error] GET /test -> error: :connection_failed"
392+ end )
393+
394+ assert warning_output =~ ":log_level option is deprecated"
395+ end
340396 end
341397
342398 alias Tesla.Middleware.Logger.Formatter
0 commit comments