1
0
mirror of https://github.com/actix/actix-website synced 2025-01-22 16:15:56 +01:00

Errors: split code lines to make where logger is wrapped clearer (#218)

This commit is contained in:
heddi.nabbisen 2021-03-01 11:29:36 +09:00 committed by GitHub
parent 501d52b485
commit d148e3e437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,15 +19,22 @@ async fn index() -> Result<&'static str, MyError> {
Err(err) Err(err)
} }
#[rustfmt::skip]
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "my_errors=debug,actix_web=info"); std::env::set_var("RUST_LOG", "my_errors=debug,actix_web=info");
std::env::set_var("RUST_BACKTRACE", "1"); std::env::set_var("RUST_BACKTRACE", "1");
env_logger::init(); env_logger::init();
HttpServer::new(|| App::new().wrap(Logger::default()).service(index)) HttpServer::new(|| {
.bind("127.0.0.1:8080")? let logger = Logger::default();
.run()
.await App::new()
.wrap(logger)
.service(index)
})
.bind("127.0.0.1:8080")?
.run()
.await
} }
// </logging> // </logging>