Added request logging
This commit is contained in:
parent
8f2512e95f
commit
818a7bb0a0
4 changed files with 85 additions and 38 deletions
|
@ -1,41 +1,41 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta property="og:title" content="{{ username }}' site'" />
|
<meta property="og:title" content="{{ username }}' site'" />
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
<meta property="og:image" content="/static/site-image.png" />
|
||||||
|
|
||||||
<title>{{ username }}' site</title>
|
<title>{{ username }}' site</title>
|
||||||
<link rel="stylesheet" href="/static/css/index.css">
|
<link rel="stylesheet" href="/static/css/index.css">
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Hi, I'm {{ username }}</h1>
|
<h1>Hi, I'm {{ username }}</h1>
|
||||||
<p>
|
<p>
|
||||||
I have a <a href="/blog">blog.</a><br>
|
I have a <a href="/blog">blog.</a><br>
|
||||||
If you have questions or input for me please send me an E-Mail to {{ email }}
|
If you have questions or input for me please send me an E-Mail to {{ email }}
|
||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
<ul style="list-style: none;">
|
<ul style="list-style: none;">
|
||||||
{% if github_account %}
|
{% if github_account %}
|
||||||
<li><img class="social-icon" src="https://github.com/favicon.ico"><a href="https://github.com/{{ github_account }}"> {{ github_account }}</a></li>
|
<li><img class="social-icon" src="https://github.com/favicon.ico"><a href="https://github.com/{{ github_account }}"> {{ github_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if twitter_account %}
|
{% if twitter_account %}
|
||||||
<li><img class="social-icon" src="https://twitter.com/favicon.ico"><a href="https://twitter.com/{{ twitter_account }}"> {{ twitter_account }}</a></li>
|
<li><img class="social-icon" src="https://twitter.com/favicon.ico"><a href="https://twitter.com/{{ twitter_account }}"> {{ twitter_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if reddit_account %}
|
{% if reddit_account %}
|
||||||
<li><img class="social-icon" src="https://reddit.com/favicon.ico"><a href="https://reddit.com/u/{{ reddit_account }}"> {{ reddit_account }}</a></li>
|
<li><img class="social-icon" src="https://reddit.com/favicon.ico"><a href="https://reddit.com/u/{{ reddit_account }}"> {{ reddit_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mastodon_account %}
|
{% if mastodon_account %}
|
||||||
<li><img class="social-icon" src="https://mastodon.social/favicon.ico"><a href="https://discord.com/"> {{ mastodon_account }}</a></li>
|
<li><img class="social-icon" src="https://mastodon.social/favicon.ico"><a href="https://discord.com/"> {{ mastodon_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if discord_account %}
|
{% if discord_account %}
|
||||||
<li><img class="social-icon" src="https://discord.com/assets/07dca80a102d4149e9736d4b162cff6f.ico"><a href="https://discord.com/"> {{ discord_account }}</a></li>
|
<li><img class="social-icon" src="https://discord.com/assets/07dca80a102d4149e9736d4b162cff6f.ico"><a href="https://discord.com/"> {{ discord_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
40
site/Cargo.lock
generated
40
site/Cargo.lock
generated
|
@ -316,6 +316,17 @@ dependencies = [
|
||||||
"syn 1.0.48",
|
"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]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -568,6 +579,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel 1.4.5",
|
"diesel 1.4.5",
|
||||||
"diesel_codegen",
|
"diesel_codegen",
|
||||||
|
"env_logger",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
@ -715,6 +727,19 @@ dependencies = [
|
||||||
"syn 1.0.48",
|
"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]]
|
[[package]]
|
||||||
name = "fake-simd"
|
name = "fake-simd"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
|
@ -995,6 +1020,12 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"
|
checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -1850,6 +1881,15 @@ dependencies = [
|
||||||
"unic-segment",
|
"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]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.22"
|
version = "1.0.22"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "crablog"
|
name = "crablog"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
authors = ["Leonard Lorenz <dev@leonardlorenz.de>"]
|
authors = ["Leonard Lorenz <dev@leonardlorenz.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -23,3 +23,5 @@ uuid = { version = "0.8.1", features = ["serde", "v5"] }
|
||||||
tera = "1.5.0"
|
tera = "1.5.0"
|
||||||
|
|
||||||
once_cell = "1.5.2"
|
once_cell = "1.5.2"
|
||||||
|
|
||||||
|
env_logger = "0.8.2"
|
||||||
|
|
|
@ -9,7 +9,8 @@ extern crate serde_derive;
|
||||||
extern crate tera;
|
extern crate tera;
|
||||||
|
|
||||||
use actix_files as fs;
|
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 tera::Tera;
|
||||||
use std::{env, sync::RwLock, collections::HashMap};
|
use std::{env, sync::RwLock, collections::HashMap};
|
||||||
use once_cell::sync::Lazy;
|
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();
|
let mut tera = Tera::new(format!("{}{}", CONFIG_MAP.read().unwrap().get("ROOT_PATH").unwrap(), "/templates/*").as_str()).unwrap();
|
||||||
tera.autoescape_on(vec![".sql"]);
|
tera.autoescape_on(vec![".sql"]);
|
||||||
|
|
||||||
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||||
|
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.data(tera)
|
.data(tera)
|
||||||
.service(routes::root)
|
.service(routes::root)
|
||||||
|
@ -62,6 +66,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(api::blog_hide_post)
|
.service(api::blog_hide_post)
|
||||||
.service(api::blog_delete_post)
|
.service(api::blog_delete_post)
|
||||||
.service(fs::Files::new("/static", "../content/static"))
|
.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()))?
|
.bind(format!("0.0.0.0:{}", CONFIG_MAP.read().unwrap().get("BIND_PORT").unwrap()))?
|
||||||
.run()
|
.run()
|
||||||
|
|
Loading…
Reference in a new issue