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
96
96
@ doc since: "1.13.0"
97
97
@ spec with_log ( keyword , ( -> result ) ) :: { result , String . t ( ) } when result: any
98
98
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
+
100
107
{ :ok , string_io } = StringIO . open ( "" )
101
108
102
109
try do
Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ defmodule ExUnit.CaptureLogTest do
78
78
end
79
79
end
80
80
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
+
81
94
describe "with_log/2" do
82
95
test "returns the result and the log" do
83
96
{ result , log } =
You can’t perform that action at this time.
0 commit comments