File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,14 @@ defmodule ExUnit.CaptureLog do
9696 @ doc since: "1.13.0"
9797 @ spec with_log ( keyword , ( -> result ) ) :: { result , String . t ( ) } when result: any
9898 def with_log ( opts \\ [ ] , fun ) when is_list ( opts ) do
99- opts = Keyword . put_new ( opts , :level , nil )
99+ opts =
100+ if opts [ :level ] == :warn do
101+ IO . warn ( "level: :warn is deprecated, please use :warning instead" )
102+ Keyword . put ( opts , :level , :warning )
103+ else
104+ opts
105+ end
106+
100107 { :ok , string_io } = StringIO . open ( "" )
101108
102109 try do
Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ defmodule ExUnit.CaptureLogTest do
7878 end
7979 end
8080
81+ test "deprecated log level" do
82+ ExUnit.CaptureIO . capture_io ( :stderr , fn ->
83+ output =
84+ capture_log ( [ level: :warn ] , fn ->
85+ Logger . log ( :warn , "ABC" )
86+ Logger . log ( :warning , "DEF" )
87+ end )
88+
89+ assert output =~ "ABC"
90+ assert output =~ "DEF"
91+ end )
92+ end
93+
8194 describe "with_log/2" do
8295 test "returns the result and the log" do
8396 { result , log } =
You can’t perform that action at this time.
0 commit comments