Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
423 stars 71 forks source link

error[E0432]: unresolved import `simplelog::TestLogger` #64

Closed blaine-dodson closed 3 years ago

blaine-dodson commented 3 years ago

Can anyone else reproduce this error, or is it just me? I create a new cargo project

Cargo.toml

[package]
name = "testing"
version = "0.1.0"
authors = ["Ammon Dodson <github@adodson.e4ward.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
simplelog = "0.8"

main.rs

use simplelog::TestLogger;

fn main() {
    println!("Hello, world!");
}

Terminal:

ammon@PC-ammon:~/Desktop/dev/testing$ cargo check
    Updating crates.io index
   Compiling autocfg v1.0.1
   Compiling libc v0.2.79
   Compiling log v0.4.11
    Checking cfg-if v0.1.10
    Checking termcolor v1.1.0
   Compiling num-traits v0.2.12
   Compiling num-integer v0.1.43
    Checking time v0.1.44
    Checking chrono v0.4.19
    Checking simplelog v0.8.0
    Checking testing v0.1.0 (/home/ammon/Desktop/dev/testing)
error[E0432]: unresolved import `simplelog::TestLogger`
 --> src/main.rs:1:5
  |
1 | use simplelog::TestLogger;
  |     ^^^^^^^^^^^----------
  |     |          |
  |     |          help: a similar name exists in the module: `TermLogger`
  |     no `TestLogger` in the root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `testing`.

To learn more, run the command again with --verbose.
Drakulix commented 3 years ago

If you wanna use the TestLogger (which is only useful for actual tests), you need to enable the "test" feature of simplelog. You Cargo.toml entry needs to look like this: simplelog = { version = "0.8", features = ["test"] }

blaine-dodson commented 3 years ago

That did it. Thank you very much.