Creates a loop which forwards all log messages send into the channel to the associated logging xdc.
(context: &Context, events: Receiver<DebugEventLogData>)
| 44 | /// Creates a loop which forwards all log messages send into the channel to the associated |
| 45 | /// logging xdc. |
| 46 | pub async fn debug_logging_loop(context: &Context, events: Receiver<DebugEventLogData>) { |
| 47 | while let Ok(DebugEventLogData { |
| 48 | time, |
| 49 | msg_id, |
| 50 | event, |
| 51 | }) = events.recv().await |
| 52 | { |
| 53 | match context |
| 54 | .write_status_update_inner( |
| 55 | &msg_id, |
| 56 | &StatusUpdateItem { |
| 57 | payload: json!({ |
| 58 | "event": event, |
| 59 | "time": time, |
| 60 | }), |
| 61 | info: None, |
| 62 | href: None, |
| 63 | summary: None, |
| 64 | document: None, |
| 65 | uid: None, |
| 66 | notify: None, |
| 67 | }, |
| 68 | time, |
| 69 | ) |
| 70 | .await |
| 71 | { |
| 72 | Err(err) => { |
| 73 | eprintln!("Can't log event to webxdc status update: {err:#}"); |
| 74 | } |
| 75 | Ok(serial) => { |
| 76 | if let Some(serial) = serial { |
| 77 | if !matches!(event, EventType::WebxdcStatusUpdate { .. }) { |
| 78 | context.emit_event(EventType::WebxdcStatusUpdate { |
| 79 | msg_id, |
| 80 | status_update_serial: serial, |
| 81 | }); |
| 82 | } |
| 83 | } else { |
| 84 | // This should not happen as the update has no `uid`. |
| 85 | error!(context, "Debug logging update is not created."); |
| 86 | }; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /// Set message as new logging webxdc if filename and chat_id fit |
| 93 | pub async fn maybe_set_logging_xdc( |
no test coverage detected