Skip to content
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

@test_log hides all logs event when exceptions occur #158

Open
omus opened this issue Mar 20, 2020 · 2 comments
Open

@test_log hides all logs event when exceptions occur #158

omus opened this issue Mar 20, 2020 · 2 comments

Comments

@omus
Copy link
Contributor

omus commented Mar 20, 2020

When using @test_log if an exception occurs you won't be able to see any Memento logs that may be helpful in determining the source of the error. For example:

julia> using Memento, Memento.TestUtils
julia> logger = getlogger()
Logger(root)
julia> @test_log logger "info" "test message" begin
           info(logger, "test message")
           warn(logger, "critical information")
           error("a problem occurred")
       end
ERROR: a problem occurred
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./REPL[3]:4 [inlined]
 [3] (::var"#3#4")() at /Users/omus/.julia/packages/Memento/UgJr2/src/memento_test.jl:35
 [4] setpropagating!(::var"#3#4", ::Logger, ::Bool) at /Users/omus/.julia/packages/Memento/UgJr2/src/loggers.jl:113
 [5] top-level scope at /Users/omus/.julia/packages/Memento/UgJr2/src/memento_test.jl:34
@rofinn
Copy link
Member

rofinn commented Mar 21, 2020

The alternative would likely result in noisy tests.

@omus
Copy link
Contributor Author

omus commented Mar 21, 2020

I was thinking of displaying all logs that occurred within the @test_log macro if an exception occurred. This would be a bit tricky as you'd need to capture the logs and emit them later which would be out of sync with anything printed directly to stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants