factoriauth/src/main.rs

59 lines
1.6 KiB
Rust

/*
factoriauth - An unofficial authentication server for Factorio
Copyright (C) 2024 lambda@xiretza.xyz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#![warn(clippy::pedantic, clippy::as_conversions)]
#![forbid(unsafe_code)]
mod auth;
mod db;
mod server;
use color_eyre::Result;
use tracing::{event, instrument, Level};
use tracing_error::ErrorLayer;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
#[instrument]
fn init() -> Result<()> {
color_eyre::install()?;
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))
.unwrap();
let fmt_layer = tracing_subscriber::fmt::layer().with_target(true);
tracing_subscriber::registry()
.with(filter_layer)
.with(fmt_layer)
.with(ErrorLayer::default())
.init();
Ok(())
}
#[tokio::main]
#[instrument]
async fn main() -> Result<()> {
init()?;
event!(Level::INFO, "Hello, world!");
tokio::spawn(server::run()).await??;
Ok(())
}