elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.37k stars 3.36k forks source link

ExUnit.CaptureLog.capture_log/2 #12092

Closed TraceyOnim closed 2 years ago

TraceyOnim commented 2 years ago

Elixir and Erlang/OTP versions

erlang 24.1.7 elixir 1.13.4-otp-24

Operating system

linux(ubuntu)

Current behavior

capture_log/2 returns an empty string if Logger.info/1 is used

capture_log(fn ->
        Logger.info("======")
end)

Expected behavior

To return the log message despite which logger is used. However , if this is how its supposed to perform, the docs should be updated to point out the case.

josevalim commented 2 years ago

The docs indeed have recently been updated to explain why this happens. Please check the docs from main: https://hexdocs.pm/ex_unit/master/ExUnit.CaptureLog.html#capture_log/2 :)

TraceyOnim commented 2 years ago

Thank you @josevalim , I have seen the part that explains