Last active
September 6, 2018 11:40
-
-
Save ian-p-cooke/67b034c43e1047f71abd243ff0007075 to your computer and use it in GitHub Desktop.
enabling crate level logging not working for actix-web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate actix_web; | |
extern crate slog_envlogger; | |
use actix_web::actix; | |
use actix_web::fs::NamedFile; | |
use actix_web::middleware; | |
use actix_web::HttpRequest; | |
use actix_web::Result; | |
use actix_web::{server, App}; | |
pub fn path(_req: &HttpRequest) -> Result<NamedFile> { | |
Ok(NamedFile::open("index.html")?) | |
} | |
fn main() -> std::result::Result<(), Box<std::error::Error>> { | |
std::env::set_var("RUST_LOG", "info"); // works | |
//std::env::set_var("RUST_LOG", "actix_web=info"); //doesn't work | |
let _guard = slog_envlogger::init()?; | |
let sys = actix::System::new("test"); | |
let addr = "0.0.0.0:3276"; | |
server::new(|| { | |
App::new() | |
.middleware(middleware::Logger::default()) | |
.resource("/", |r| r.f(path)) | |
}).bind(addr) | |
.expect(&format!("could not bind to {}", addr)) | |
.start(); | |
let _ = sys.run(); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should log
in either case.