File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,20 @@ defmodule Logger do
343
343
Logger.Config . configure ( Dict . take ( options , @ valid_options ) )
344
344
end
345
345
346
+ @ doc """
347
+ Flushes the Logger.
348
+
349
+ This basically guarantees all messages sent to the
350
+ Logger prior to this call will be processed. This is useful
351
+ for testing and it should not be called in production code.
352
+ """
353
+ @ spec flush :: :ok
354
+ def flush do
355
+ _ = GenEvent . which_handlers ( :error_logger )
356
+ _ = GenEvent . which_handlers ( Logger )
357
+ :ok
358
+ end
359
+
346
360
@ doc """
347
361
Adds a new backend.
348
362
Original file line number Diff line number Diff line change @@ -39,8 +39,7 @@ defmodule Logger.Case do
39
39
Logger . configure ( level: level )
40
40
capture_io ( :user , fn ->
41
41
fun . ( )
42
- GenEvent . which_handlers ( :error_logger )
43
- GenEvent . which_handlers ( Logger )
42
+ Logger . flush ( )
44
43
end )
45
44
after
46
45
Logger . configure ( level: :debug )
You can’t perform that action at this time.
0 commit comments