logging updated
This commit is contained in:
parent
9c059055b6
commit
d7b4a45a9a
11
src/lib.rs
11
src/lib.rs
|
|
@ -7,30 +7,33 @@ use axum::response::{IntoResponse, Response};
|
||||||
use axum_session::{SessionConfig, SessionLayer, SessionStore};
|
use axum_session::{SessionConfig, SessionLayer, SessionStore};
|
||||||
use axum_session_auth::{AuthConfig, AuthSessionLayer};
|
use axum_session_auth::{AuthConfig, AuthSessionLayer};
|
||||||
use axum_session_mongo::SessionMongoPool;
|
use axum_session_mongo::SessionMongoPool;
|
||||||
|
use chrono::Utc;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use mongodb::{bson::oid::ObjectId, Client};
|
use mongodb::{bson::oid::ObjectId, Client};
|
||||||
use rlg::{config::Config, macro_info_log};
|
use rlg::{config::Config, macro_info_log};
|
||||||
|
|
||||||
pub async fn run() -> Result<()> {
|
pub async fn run() -> Result<()> {
|
||||||
|
let id = "server";
|
||||||
|
|
||||||
init_logging();
|
init_logging();
|
||||||
macro_info_log!(&chrono::Utc::now().to_string(), "server", "Server Initializing...");
|
macro_info_log!(&Utc::now().to_string(), id, "Server Initializing...");
|
||||||
let db = get_db_client().await?;
|
let db = get_db_client().await?;
|
||||||
let session_store = session(db.clone()).await?;
|
let session_store = session(db.clone()).await?;
|
||||||
let auth_config = AuthConfig::<ObjectId>::default();
|
let auth_config = AuthConfig::<ObjectId>::default();
|
||||||
|
|
||||||
macro_info_log!(&chrono::Utc::now().to_string(), "server", "Routes Initializing...");
|
macro_info_log!(&Utc::now().to_string(), id, "Routes Initializing...");
|
||||||
|
|
||||||
let app = router()
|
let app = router()
|
||||||
.layer(SessionLayer::new(session_store))
|
.layer(SessionLayer::new(session_store))
|
||||||
.layer(AuthSessionLayer::<User, ObjectId, SessionMongoPool, Client>
|
.layer(AuthSessionLayer::<User, ObjectId, SessionMongoPool, Client>
|
||||||
::new(Some(db)).with_config(auth_config)
|
::new(Some(db)).with_config(auth_config)
|
||||||
);
|
);
|
||||||
macro_info_log!(&chrono::Utc::now().to_string(), "server", "Routes Initialized");
|
macro_info_log!(&Utc::now().to_string(), id, "Routes Initialized");
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||||
|
|
||||||
axum::serve(listener, app).await?;
|
axum::serve(listener, app).await?;
|
||||||
|
|
||||||
macro_info_log!(&chrono::Utc::now().to_string(), "server", "Server Initialized");
|
macro_info_log!(&Utc::now().to_string(), id, "Server Initialized");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue