invenia / Memento.jl

A flexible logging library for Julia
https://invenia.github.io/Memento.jl/latest
Other
87 stars 14 forks source link

Test for multiple log messages #183

Open glennmoy opened 2 years ago

glennmoy commented 2 years ago

It would be nice of @test_log could test for multiple messages at the same level from a particular logger. Below is a MWE of what I was hoping to do:

@test_log(LOGGER, "info", ("message 1", "message 2"), f(args...))

where f(args..) might record:

[info | LOGGER]: This is message 1
[info | LOGGER]: This is message 2

Right now I'm just running f twice, which isn't that inconvenient but might be if it were an expensive function.

rofinn commented 2 years ago

Yeah, looks like the current syntax in base Julia does what you want now. The API for those macros was intended to mimic Julia pre-1.0, but it looks like base has made a bunch of changes since then. I don't love the current base syntax, but I think it's worth keeping both APIs in sync as best as possible. Might be related to #146.

https://docs.julialang.org/en/v1/stdlib/Test/#Test.@test_logs