Skip to content

Flush error_logger before capturing #5280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/ex_unit/lib/ex_unit/capture_log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ defmodule ExUnit.CaptureLog do
Returns the binary which is the captured output.

This function mutes the `:console` backend
and captures any log messages sent to Logger.
and captures any log messages sent to Logger from the calling
processes. It is possible to ensure explicit log messages from other
processes are captured by waiting for their exit or monitor
signal. This does not guarantee to capture VM generated log messages
when a process that is spawned using a low level `Kernel` spawn function
(e.g. `Kernel.spawn/1`) raises an exception that isn't rescued or a throw
that isn't caught. A `Task`, or other OTP process, will send explicit logs
that are sent before its exit or monitor signal and will not cause VM
generated log messages.

Note that when the `async` is set to `true`,
the messages from another test might be captured.
Expand All @@ -59,6 +67,7 @@ defmodule ExUnit.CaptureLog do
{:ok, string_io} = StringIO.open("")

try do
_ = :gen_event.which_handlers(:error_logger)
:ok = add_capture(string_io, opts)
ref = ExUnit.CaptureServer.log_capture_on(self())

Expand Down