1 //! Do not put multiple tests in this file. Tests in the same file run in the 2 //! same executable, so if there are several tests in one file, only one test 3 //! will successfully be able to initialize the logger. 4 5 use std::env; 6 7 #[test] env_log_level()8fn env_log_level() { 9 env::set_var("RUST_LOG", "debug"); 10 assert!(logger::init(Default::default())); 11 12 if cfg!(target_os = "android") { 13 // android_logger does not read from environment variables 14 assert_eq!(log::max_level(), log::LevelFilter::Off); 15 } else { 16 // env_logger reads its log level from the "RUST_LOG" environment variable 17 assert_eq!(log::max_level(), log::LevelFilter::Debug); 18 } 19 env::remove_var("RUST_LOG"); 20 } 21