Function loggy::assert_logs

source ·
pub fn assert_logs<Code: FnOnce() -> Result, Result>(
    expected_log: &str,
    code: Code
) -> Result
Expand description

Assert that the collected log messages are as expected.

The expected string is passed through unindent prior to the comparison, to enable proper indentation of the tests data in the code.

Notes

The rust log facade mandates using a single global logger. Therefore, only one test can capture the log at any given time, using a global Mutex. Therefore, nesting this inside itself, assert_panics or assert_logs_panics will deadlock.

Panics

If the actual log is different from the expected log.