- fix: warnings about unused variables

- add: LOG_LEVEL env variable
This commit is contained in:
2024-11-26 13:15:33 -05:00
parent e494860e9a
commit 815cb210dc
3 changed files with 15 additions and 17 deletions

View File

@@ -77,31 +77,31 @@ impl DatabaseClientTrait for DatabaseClient {
async fn store_password_reset( async fn store_password_reset(
&mut self, &mut self,
email: &str, _email: &str,
reset_token: &str, _reset_token: &str,
expires_at: DateTime<Utc>, _expires_at: DateTime<Utc>,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
async fn get_password_reset( async fn get_password_reset(
&self, &self,
reset_token: &str, _reset_token: &str,
) -> Result<Option<PasswordReset>, Box<dyn std::error::Error>> { ) -> Result<Option<PasswordReset>, Box<dyn std::error::Error>> {
todo!() todo!()
} }
async fn delete_password_reset( async fn delete_password_reset(
&self, &self,
reset_token: &str, _reset_token: &str,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
async fn update_user_password( async fn update_user_password(
&self, &self,
email: &str, _email: &str,
hashed_password: &str, _hashed_password: &str,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }

View File

@@ -6,9 +6,10 @@ use auth_service::grpc::MyAuthService;
use dotenv::dotenv; use dotenv::dotenv;
use std::env; use std::env;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use std::str::FromStr;
use tokio::{select, signal}; use tokio::{select, signal};
use tonic::transport::Server; use tonic::transport::Server;
use tracing::info; use tracing::{info, Level};
use warp::Filter; use warp::Filter;
mod consul_registration; mod consul_registration;
@@ -20,9 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv().ok(); dotenv().ok();
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .with_max_level(Level::from_str(&env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string())).unwrap_or_else(|_| Level::INFO))
.with_thread_names(true)
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
.init(); .init();
// Set the gRPC server address // Set the gRPC server address

View File

@@ -7,10 +7,11 @@ use dotenv::dotenv;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use std::env; use std::env;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use tokio::{select, signal}; use tokio::{select, signal};
use tonic::transport::Server; use tonic::transport::Server;
use tracing::info; use tracing::{info, Level};
use warp::Filter; use warp::Filter;
mod consul_registration; mod consul_registration;
@@ -19,9 +20,7 @@ mod consul_registration;
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv().ok(); dotenv().ok();
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .with_max_level(Level::from_str(&env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string())).unwrap_or_else(|_| Level::INFO))
.with_thread_names(true)
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
.init(); .init();
let addr = env::var("DATABASE_SERVICE_ADDR").unwrap_or_else(|_| "127.0.0.1".to_string()); let addr = env::var("DATABASE_SERVICE_ADDR").unwrap_or_else(|_| "127.0.0.1".to_string());
@@ -69,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}; };
// Pass `shared_cache` into services as needed // Pass `shared_cache` into services as needed
println!("Database Service running on {}", address); info!("Database Service running on {}", address);
tokio::spawn(Server::builder() tokio::spawn(Server::builder()
.add_service(DatabaseServiceServer::new(database_service)) .add_service(DatabaseServiceServer::new(database_service))
.serve(address)); .serve(address));