testing_logger 0.1.1

Supports writing tests to verify `log` crate calls
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented1 out of 4 items with examples
  • Size
  • Source code size: 8.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • brucechapman/rust_testing_logger
    8 5 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • brucechapman

testing_logger

A Rust library to support testing of code that uses log crate.

Version Documentation license Status

Example

#[macro_use]
extern crate log;
use log::Level;
extern crate testing_logger;

#[test]
fn test_something() {
    testing_logger::setup();
    warn!("Something went wrong with {}", 10);
    testing_logger::validate( |captured_logs| {
        assert_eq!(captured_logs.len(), 1);
        assert_eq!(captured_logs[0].body, "Something went wrong with 10");
        assert_eq!(captured_logs[0].level, Level::Warn);
    });
}