Log level with env

    0

    0

    Giovanny Gongora

    Codiga's Rust Recipes

    level based in env variables

    use std::env;
    use env_logger::Builder;
    
    fn main() {
      Builder::new()
      .parse(&env::var("MY_APP_LOG").unwrap_or_default())
      .init();
      log::info!("informational message");
      log::warn!("warning message");
      log::error!("this is an error {}", "message");
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.