Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add More Logging #98

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading