5
#[macro_use]
extern crate log;

fn whatever() {
    info!("whatever")
}

#[test]
fn test() {
    whatever();
}

I want to see the log after running unit tests (cargo test), how is it possible now?

盛安安
  • 1,110
  • 1
  • 8
  • 21

1 Answers1

5

The log crate doesn't do any logging by itself. From the main documentation page:

If no logging implementation is selected, the facade falls back to a "noop" implementation that ignores all log messages.

For your logging messages to go anywhere, you have to initialize a particular logging implementation, such as env_logger. However, it seems that right now, there is no way to perform initialization before tests are run.

Community
  • 1
  • 1
Francis Gagné
  • 60,274
  • 7
  • 180
  • 155