From c4df3356c7ea54211a817dbb2f195bc675435cd2 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 6 Mar 2019 19:45:45 -0800 Subject: [PATCH] enable logger --- async_db/src/main.rs | 7 ++++--- basics/Cargo.toml | 4 ---- basics/src/main.rs | 5 +++-- r2d2/src/main.rs | 4 +++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/async_db/src/main.rs b/async_db/src/main.rs index fc3d910d..11027032 100644 --- a/async_db/src/main.rs +++ b/async_db/src/main.rs @@ -11,7 +11,9 @@ This project illustrates two examples: */ use std::io; -use actix_web::{web, App, Error as AWError, HttpResponse, HttpServer, State}; +use actix_web::{ + middleware, web, App, Error as AWError, HttpResponse, HttpServer, State, +}; use futures::future::{join_all, ok as fut_ok, Future}; use r2d2_sqlite; use r2d2_sqlite::SqliteConnectionManager; @@ -79,8 +81,7 @@ fn main() -> io::Result<()> { HttpServer::new(move || { App::new() .state(pool.clone()) - // enable logger - // .middleware(middleware::Logger::default()) + .middleware(middleware::Logger::default()) .service( web::resource("/asyncio_weather") .route(web::get().to_async(asyncio_weather)), diff --git a/basics/Cargo.toml b/basics/Cargo.toml index 95c7608b..518a4637 100644 --- a/basics/Cargo.toml +++ b/basics/Cargo.toml @@ -11,10 +11,6 @@ actix-web = { git="https://github.com/actix/actix-web.git", branch = "1.0" } actix-session = { git="https://github.com/actix/actix-web.git", branch = "1.0" } actix-staticfiles = { git="https://github.com/actix/actix-web.git", branch = "1.0" } -#actix-web = { path="../../actix-web/" } -#actix-session = { path="../../actix-web/actix-session/" } -#actix-staticfiles = { path="../../actix-web/actix-staticfiles/" } - futures = "0.1.25" env_logger = "0.5" bytes = "0.4" diff --git a/basics/src/main.rs b/basics/src/main.rs index ccd73b05..d4f6eae0 100644 --- a/basics/src/main.rs +++ b/basics/src/main.rs @@ -5,7 +5,8 @@ use actix_staticfiles as fs; use actix_web::extract::Path; use actix_web::http::{header, Method, StatusCode}; use actix_web::{ - error, guard, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, + error, guard, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, + Result, }; use bytes::Bytes; use futures::unsync::mpsc; @@ -79,7 +80,7 @@ fn main() -> io::Result<()> { HttpServer::new(|| { App::new() // enable logger - // .middleware(middleware::Logger::default()) + .middleware(middleware::Logger::default()) // cookie session middleware .middleware(CookieSession::signed(&[0; 32]).secure(false)) // register favicon diff --git a/r2d2/src/main.rs b/r2d2/src/main.rs index abe564d1..da83a8a6 100644 --- a/r2d2/src/main.rs +++ b/r2d2/src/main.rs @@ -2,7 +2,8 @@ use std::io; use actix_web::{ - blocking, extract::Path, web, App, Error, HttpResponse, HttpServer, State, + blocking, extract::Path, middleware, web, App, Error, HttpResponse, HttpServer, + State, }; use futures::Future; use r2d2::Pool; @@ -48,6 +49,7 @@ fn main() -> io::Result<()> { HttpServer::new(move || { App::new() .state(pool.clone()) // <- store db pool in app state + .middleware(middleware::Logger::default()) .route("/{name}", web::get().to_async(index)) }) .bind("127.0.0.1:8080")?