Skip to content

Commit

Permalink
cln-rpc: Log requests and responses
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Mar 28, 2022
1 parent 98509bf commit 9d34284
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions contrib/msggen/msggen/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def generate(self, service: Service) -> None:
use anyhow::Result;
use std::path::{{Path, PathBuf}};
use cln_rpc::model::requests;
use log::debug;
use log::{{debug, trace}};
use tonic::{{Code, Status}};
#[derive(Clone)]
Expand Down Expand Up @@ -480,7 +480,8 @@ def generate(self, service: Service) -> None:
) -> Result<tonic::Response<pb::{method.response.typename}>, tonic::Status> {{
let req = request.into_inner();
let req: requests::{method.request.typename} = (&req).into();
debug!("Client asked for getinfo");
debug!("Client asked for {name}");
trace!("{name} request: {{:?}}", req);
let mut rpc = ClnRpc::new(&self.rpc_path)
.await
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
Expand All @@ -490,9 +491,10 @@ def generate(self, service: Service) -> None:
Code::Unknown,
format!("Error calling method {method.name}: {{:?}}", e)))?;
match result {{
Response::{method.name}(r) => Ok(
tonic::Response::new((&r).into())
),
Response::{method.name}(r) => {{
trace!("{name} response: {{:?}}", r);
Ok(tonic::Response::new((&r).into()))
}},
r => Err(Status::new(
Code::Internal,
format!(
Expand Down

0 comments on commit 9d34284

Please sign in to comment.