aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-03-04 21:59:50 +0100
committerFxQnLr <[email protected]>2024-03-04 21:59:50 +0100
commit85c63c2ca8448428e2db93cb9d4f284a4e314ed7 (patch)
tree0180a452dd354b067470618e6dbdc330649287cb /src/main.rs
parent0a058ba2064d323451462a79c71580dea7d8ec8c (diff)
downloadwebol-85c63c2ca8448428e2db93cb9d4f284a4e314ed7.tar
webol-85c63c2ca8448428e2db93cb9d4f284a4e314ed7.tar.gz
webol-85c63c2ca8448428e2db93cb9d4f284a4e314ed7.zip
#20. Set offset manually through config
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 8978e58..00fc6ce 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,11 +11,12 @@ use axum::{
11}; 11};
12use dashmap::DashMap; 12use dashmap::DashMap;
13use sqlx::PgPool; 13use sqlx::PgPool;
14use time::UtcOffset;
14use std::{env, sync::Arc}; 15use std::{env, sync::Arc};
15use tokio::sync::broadcast::{channel, Sender}; 16use tokio::sync::broadcast::{channel, Sender};
16use tracing::{info, level_filters::LevelFilter}; 17use tracing::{info, level_filters::LevelFilter};
17use tracing_subscriber::{ 18use tracing_subscriber::{
18 fmt::{self, time::UtcTime}, 19 fmt::{self, time::OffsetTime},
19 prelude::*, 20 prelude::*,
20 EnvFilter, 21 EnvFilter,
21}; 22};
@@ -77,16 +78,18 @@ impl Modify for SecurityAddon {
77async fn main() -> color_eyre::eyre::Result<()> { 78async fn main() -> color_eyre::eyre::Result<()> {
78 color_eyre::install()?; 79 color_eyre::install()?;
79 80
81 let config = Config::load()?;
82
80 let time_format = 83 let time_format =
81 time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); 84 time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]");
82 let loc = UtcTime::new(time_format); 85 let time = OffsetTime::new(UtcOffset::from_hms(config.timeoffset, 0, 0)?, time_format);
83 86
84 let file_appender = tracing_appender::rolling::daily("logs", "webol.log"); 87 let file_appender = tracing_appender::rolling::daily("logs", "webol.log");
85 let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); 88 let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
86 89
87 tracing_subscriber::registry() 90 tracing_subscriber::registry()
88 .with(fmt::layer().with_writer(non_blocking).with_ansi(false)) 91 .with(fmt::layer().with_writer(non_blocking).with_ansi(false))
89 .with(fmt::layer().with_timer(loc)) 92 .with(fmt::layer().with_timer(time))
90 .with( 93 .with(
91 EnvFilter::builder() 94 EnvFilter::builder()
92 .with_default_directive(LevelFilter::INFO.into()) 95 .with_default_directive(LevelFilter::INFO.into())
@@ -96,8 +99,6 @@ async fn main() -> color_eyre::eyre::Result<()> {
96 99
97 let version = env!("CARGO_PKG_VERSION"); 100 let version = env!("CARGO_PKG_VERSION");
98 101
99 let config = Config::load()?;
100
101 info!("start webol v{}", version); 102 info!("start webol v{}", version);
102 103
103 let db = init_db_pool(&config.database_url).await; 104 let db = init_db_pool(&config.database_url).await;