(bp: &backend::BasePayload, req_body: &[u8], resp: &T)
| 685 | } |
| 686 | |
| 687 | async fn log_request_response<T>(bp: &backend::BasePayload, req_body: &[u8], resp: &T) |
| 688 | where |
| 689 | T: Serialize + BasePayloadResultProvider, |
| 690 | { |
| 691 | // The incoming request is an async answer. |
| 692 | // This is already logged by the backend client. |
| 693 | if bp.is_answer() { |
| 694 | return; |
| 695 | } |
| 696 | |
| 697 | let be_req_log = stream_pb::BackendInterfacesRequest { |
| 698 | sender_id: hex::encode(&bp.sender_id), |
| 699 | receiver_id: hex::encode(&bp.receiver_id), |
| 700 | transaction_id: bp.transaction_id, |
| 701 | message_type: format!("{:?}", bp.message_type), |
| 702 | request_body: String::from_utf8(req_body.to_vec()).unwrap_or_default(), |
| 703 | response_body: serde_json::to_string(resp).unwrap_or_default(), |
| 704 | result_code: format!("{:?}", resp.base_payload().result.result_code), |
| 705 | time: Some(Utc::now().into()), |
| 706 | ..Default::default() |
| 707 | }; |
| 708 | |
| 709 | if let Err(e) = stream::backend_interfaces::log_request(be_req_log).await { |
| 710 | error!(error = %e.full(), "Log Backend Interfaces request error"); |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | #[cfg(test)] |
| 715 | pub mod test { |
no test coverage detected