| 8 | use chirpstack_api::stream; |
| 9 | |
| 10 | pub async fn get_log_sender() -> Option<Sender<stream::BackendInterfacesRequest>> { |
| 11 | let conf = config::get(); |
| 12 | if conf.monitoring.backend_interfaces_log_max_history == 0 { |
| 13 | return None; |
| 14 | } |
| 15 | |
| 16 | let (tx, mut rx) = mpsc::channel(100); |
| 17 | |
| 18 | tokio::spawn(async move { |
| 19 | while let Some(pl) = rx.recv().await { |
| 20 | tokio::spawn(async move { |
| 21 | if let Err(e) = log_request(pl).await { |
| 22 | error!(error = %e, "Log request error"); |
| 23 | } |
| 24 | }); |
| 25 | } |
| 26 | }); |
| 27 | |
| 28 | Some(tx) |
| 29 | } |
| 30 | |
| 31 | pub async fn log_request(pl: stream::BackendInterfacesRequest) -> Result<()> { |
| 32 | let conf = config::get(); |