Skip to content

Commit

Permalink
add more logging (#98)
Browse files Browse the repository at this point in the history
Co-authored-by: Kitipong Sirirueangsakul <[email protected]>
  • Loading branch information
warittornc and RogerKSI authored Nov 6, 2024
1 parent 318444c commit 911ccaa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bothan-api/server/src/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use semver::Version;
use tonic::{Request, Response, Status};
use tracing::{error, info};
use tracing::{debug, error, info};

use bothan_core::manager::crypto_asset_info::error::{PushMonitoringRecordError, SetRegistryError};
use bothan_core::manager::CryptoAssetInfoManager;
Expand All @@ -28,12 +28,14 @@ impl BothanServer {
}
}

// TODO: cleanup logging with span
#[tonic::async_trait]
impl BothanService for BothanServer {
async fn get_info(
&self,
_: Request<GetInfoRequest>,
) -> Result<Response<GetInfoResponse>, Status> {
info!("received get info request");
let info = self
.manager
.get_info()
Expand All @@ -47,7 +49,7 @@ impl BothanService for BothanServer {
active_sources: info.active_sources,
monitoring_enabled: info.monitoring_enabled,
});

debug!("response: {:?}", response);
Ok(response)
}

Expand All @@ -56,6 +58,7 @@ impl BothanService for BothanServer {
request: Request<UpdateRegistryRequest>,
) -> Result<Response<UpdateRegistryResponse>, Status> {
info!("received update registry request");
debug!("request: {:?}", request);
let update_registry_request = request.into_inner();

let version = Version::parse(&update_registry_request.version)
Expand Down Expand Up @@ -103,6 +106,7 @@ impl BothanService for BothanServer {
request: Request<PushMonitoringRecordsRequest>,
) -> Result<Response<PushMonitoringRecordsResponse>, Status> {
info!("received push monitoring records request");
debug!("request: {:?}", request);
let request = request.into_inner();
let push_result = self
.manager
Expand Down Expand Up @@ -142,6 +146,7 @@ impl BothanService for BothanServer {
request: Request<GetPricesRequest>,
) -> Result<Response<GetPricesResponse>, Status> {
info!("received get price request");
debug!("request: {:?}", request);
let price_request = request.into_inner();
let (uuid, price_states) = self
.manager
Expand All @@ -158,7 +163,8 @@ impl BothanService for BothanServer {
.zip(price_states)
.map(|(id, state)| parse_price_state(id, state))
.collect::<Vec<Price>>();

Ok(Response::new(GetPricesResponse { uuid, prices }))
let response = Response::new(GetPricesResponse { uuid, prices });
debug!("response: {:?}", response);
Ok(response)
}
}

0 comments on commit 911ccaa

Please sign in to comment.