log requests
This commit is contained in:
parent
c523993ba5
commit
07cd3b1ed4
3 changed files with 34 additions and 7 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
@ -1089,6 +1089,29 @@ version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
|
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_filter"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_logger"
|
||||||
|
version = "0.11.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0"
|
||||||
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"env_filter",
|
||||||
|
"humantime",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -1117,6 +1140,7 @@ dependencies = [
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
"comrak",
|
"comrak",
|
||||||
"cyborgtime",
|
"cyborgtime",
|
||||||
|
"env_logger",
|
||||||
"glob",
|
"glob",
|
||||||
"lol_html",
|
"lol_html",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
|
@ -1444,6 +1468,12 @@ version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper"
|
name = "hyper"
|
||||||
version = "1.5.1"
|
version = "1.5.1"
|
||||||
|
|
|
@ -33,6 +33,7 @@ urlencoding = "2.1"
|
||||||
regex = "1.11"
|
regex = "1.11"
|
||||||
cyborgtime = "2.1.1"
|
cyborgtime = "2.1.1"
|
||||||
walkdir = "2.5"
|
walkdir = "2.5"
|
||||||
|
env_logger = "0.11"
|
||||||
|
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
pedantic = "warn"
|
pedantic = "warn"
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,6 +1,6 @@
|
||||||
use actix_files::Files;
|
use actix_files::Files;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
middleware::{Compress, DefaultHeaders},
|
middleware::{Compress, DefaultHeaders, Logger},
|
||||||
web, App, HttpServer,
|
web, App, HttpServer,
|
||||||
};
|
};
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
|
@ -29,16 +29,12 @@ async fn main() -> Result<()> {
|
||||||
config.fc.port.unwrap(),
|
config.fc.port.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
println!(
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
"Listening to {}://{}:{}",
|
|
||||||
config.clone().fc.scheme.unwrap(),
|
|
||||||
addr.0,
|
|
||||||
addr.1
|
|
||||||
);
|
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(web::Data::new(config.clone()))
|
.app_data(web::Data::new(config.clone()))
|
||||||
|
.wrap(Logger::default().log_target(config.fc.app_name.clone().unwrap_or_default()))
|
||||||
.wrap(Compress::default())
|
.wrap(Compress::default())
|
||||||
.wrap(
|
.wrap(
|
||||||
DefaultHeaders::new()
|
DefaultHeaders::new()
|
||||||
|
|
Loading…
Reference in a new issue