diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
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 | }; |
12 | use dashmap::DashMap; | 12 | use dashmap::DashMap; |
13 | use sqlx::PgPool; | 13 | use sqlx::PgPool; |
14 | use time::UtcOffset; | ||
14 | use std::{env, sync::Arc}; | 15 | use std::{env, sync::Arc}; |
15 | use tokio::sync::broadcast::{channel, Sender}; | 16 | use tokio::sync::broadcast::{channel, Sender}; |
16 | use tracing::{info, level_filters::LevelFilter}; | 17 | use tracing::{info, level_filters::LevelFilter}; |
17 | use tracing_subscriber::{ | 18 | use 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 { | |||
77 | async fn main() -> color_eyre::eyre::Result<()> { | 78 | async 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; |