MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / log_request_response

Function log_request_response

chirpstack/src/api/backend/mod.rs:687–712  ·  view source on GitHub ↗
(bp: &backend::BasePayload, req_body: &[u8], resp: &T)

Source from the content-addressed store, hash-verified

685}
686
687async fn log_request_response<T>(bp: &backend::BasePayload, req_body: &[u8], resp: &T)
688where
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)]
715pub mod test {

Callers 5

_handle_requestFunction · 0.85
handle_pr_start_reqFunction · 0.85
handle_pr_stop_reqFunction · 0.85
handle_xmit_data_reqFunction · 0.85
handle_home_ns_reqFunction · 0.85

Calls 5

is_answerMethod · 0.80
encodeFunction · 0.50
log_requestFunction · 0.50
to_vecMethod · 0.45
intoMethod · 0.45

Tested by

no test coverage detected