Need an option to prevent cargo test
from initializing logging
#7743
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
I'm trying to unit test program functionality that reopens log files on receiving a SIGHUP. My unit test does this:
My
init_logging
andreinit_logging
functions call into my log provider, which islog4rs
. After running the above code, I'd be rereading "logfile" to make sure it contains the "POST-ROTATION" message, and "logfile.old" to make sure it contains the "PRE-ROTATION" and "MID-ROTATION" messages.Problem is, it doesn't work, because it panics on
init_logging(&logconfig).unwrap()
. log4rs is callinglog::set_logger
and getting back aSetLoggerError
, becausecargo test
has already initialized before it ever calls into my test.There seems to be no way around this without abandoning the cargo test framework altogether, since as of 0.4 the
log
crate no longer provides any mechanism for de-initializing logging. I'd like to be able to add some attribute like#[test_no_init_logging]
to my unit test to tell cargo "don't touch".The text was updated successfully, but these errors were encountered: