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
343343 Logger.Config . configure ( Dict . take ( options , @ valid_options ) )
344344 end
345345
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+
346360 @ doc """
347361 Adds a new backend.
348362
Original file line number Diff line number Diff line change @@ -39,8 +39,7 @@ defmodule Logger.Case do
3939 Logger . configure ( level: level )
4040 capture_io ( :user , fn ->
4141 fun . ( )
42- GenEvent . which_handlers ( :error_logger )
43- GenEvent . which_handlers ( Logger )
42+ Logger . flush ( )
4443 end )
4544 after
4645 Logger . configure ( level: :debug )
You can’t perform that action at this time.
0 commit comments