From ba5ab968974abd8d7e41314e0a7b81786bea1c4d Mon Sep 17 00:00:00 2001 From: shiomiyan <35842766+shiomiyan@users.noreply.github.com> Date: Mon, 29 Nov 2021 23:46:19 +0900 Subject: [PATCH] add logger for askama template example (#466) --- template_engines/askama/Cargo.toml | 1 + template_engines/askama/src/main.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/template_engines/askama/Cargo.toml b/template_engines/askama/Cargo.toml index 27b7050b..45094212 100644 --- a/template_engines/askama/Cargo.toml +++ b/template_engines/askama/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Nikolay Kim "] edition = "2018" [dependencies] +env_logger = "0.8" actix-web = "3" askama = "0.9" diff --git a/template_engines/askama/src/main.rs b/template_engines/askama/src/main.rs index 5b0e6fa5..ca98cce7 100644 --- a/template_engines/askama/src/main.rs +++ b/template_engines/askama/src/main.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use actix_web::{web, App, HttpResponse, HttpServer, Result}; +use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result}; use askama::Template; #[derive(Template)] @@ -30,9 +30,14 @@ async fn index(query: web::Query>) -> Result std::io::Result<()> { + std::env::set_var("RUST_LOG", "actix_web=info"); + env_logger::init(); + // start http server HttpServer::new(move || { - App::new().service(web::resource("/").route(web::get().to(index))) + App::new() + .wrap(middleware::Logger::default()) + .service(web::resource("/").route(web::get().to(index))) }) .bind("127.0.0.1:8080")? .run()