mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-21 13:38:21 -05:00
Merge branch 'logging' into 'rolling'
add logging middleware See merge request NEON-MMD/websurfx!1
This commit is contained in:
commit
bb61ee3afe
30
Cargo.lock
generated
30
Cargo.lock
generated
@ -758,6 +758,19 @@ dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
|
||||
dependencies = [
|
||||
"humantime",
|
||||
"is-terminal",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.1"
|
||||
@ -1174,6 +1187,12 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.12.36"
|
||||
@ -2775,6 +2794,15 @@ dependencies = [
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
@ -3324,8 +3352,10 @@ dependencies = [
|
||||
"actix-files",
|
||||
"actix-web",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"fake-useragent",
|
||||
"handlebars",
|
||||
"log",
|
||||
"reqwest 0.11.16",
|
||||
"scraper",
|
||||
"serde",
|
||||
|
@ -16,3 +16,5 @@ actix-files = {version="0.6.2"}
|
||||
serde_json = {version="*"}
|
||||
fake-useragent = {version="*"}
|
||||
clap = {version="*", features = ["derive"] }
|
||||
env_logger = "0.10.0"
|
||||
log = "0.4.17"
|
||||
|
@ -3,8 +3,9 @@ use std::ops::RangeInclusive;
|
||||
use websurfx::server::routes;
|
||||
|
||||
use actix_files as fs;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_web::{middleware::Logger, web, App, HttpServer};
|
||||
use clap::{command, Parser};
|
||||
use env_logger::Env;
|
||||
use handlebars::Handlebars;
|
||||
|
||||
#[derive(Parser, Debug, Default)]
|
||||
@ -38,7 +39,9 @@ fn is_port_in_range(s: &str) -> Result<u16, String> {
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let args = CliArgs::parse();
|
||||
|
||||
println!("started server on port {}", args.port);
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
|
||||
log::info!("started server on port {}", args.port);
|
||||
|
||||
let mut handlebars: Handlebars = Handlebars::new();
|
||||
|
||||
@ -51,6 +54,7 @@ async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(handlebars_ref.clone())
|
||||
.wrap(Logger::default())
|
||||
// Serve images and static files (css and js files).
|
||||
.service(fs::Files::new("/static", "./public/static").show_files_listing())
|
||||
.service(fs::Files::new("/images", "./public/images").show_files_listing())
|
||||
|
Loading…
Reference in New Issue
Block a user