Added request logging
This commit is contained in:
parent
8f2512e95f
commit
818a7bb0a0
4 changed files with 85 additions and 38 deletions
40
site/Cargo.lock
generated
40
site/Cargo.lock
generated
|
@ -316,6 +316,17 @@ dependencies = [
|
|||
"syn 1.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
|
@ -568,6 +579,7 @@ dependencies = [
|
|||
"chrono",
|
||||
"diesel 1.4.5",
|
||||
"diesel_codegen",
|
||||
"env_logger",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
|
@ -715,6 +727,19 @@ dependencies = [
|
|||
"syn 1.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
|
@ -995,6 +1020,12 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
|
@ -1850,6 +1881,15 @@ dependencies = [
|
|||
"unic-segment",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.22"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "crablog"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Leonard Lorenz <dev@leonardlorenz.de>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -23,3 +23,5 @@ uuid = { version = "0.8.1", features = ["serde", "v5"] }
|
|||
tera = "1.5.0"
|
||||
|
||||
once_cell = "1.5.2"
|
||||
|
||||
env_logger = "0.8.2"
|
||||
|
|
|
@ -9,7 +9,8 @@ extern crate serde_derive;
|
|||
extern crate tera;
|
||||
|
||||
use actix_files as fs;
|
||||
use actix_web::{App, HttpServer};
|
||||
use actix_web::{App, HttpServer, middleware::Logger};
|
||||
use env_logger::Env;
|
||||
use tera::Tera;
|
||||
use std::{env, sync::RwLock, collections::HashMap};
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -47,6 +48,9 @@ async fn main() -> std::io::Result<()> {
|
|||
let mut tera = Tera::new(format!("{}{}", CONFIG_MAP.read().unwrap().get("ROOT_PATH").unwrap(), "/templates/*").as_str()).unwrap();
|
||||
tera.autoescape_on(vec![".sql"]);
|
||||
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
|
||||
|
||||
App::new()
|
||||
.data(tera)
|
||||
.service(routes::root)
|
||||
|
@ -62,6 +66,7 @@ async fn main() -> std::io::Result<()> {
|
|||
.service(api::blog_hide_post)
|
||||
.service(api::blog_delete_post)
|
||||
.service(fs::Files::new("/static", "../content/static"))
|
||||
.wrap(Logger::new("%a %r %t"))
|
||||
})
|
||||
.bind(format!("0.0.0.0:{}", CONFIG_MAP.read().unwrap().get("BIND_PORT").unwrap()))?
|
||||
.run()
|
||||
|
|
Loading…
Reference in a new issue