(
&self,
udid: &str,
seconds: f64,
limit: usize,
filters: &LogFilters,
)
| 566 | } |
| 567 | |
| 568 | pub fn recent_logs( |
| 569 | &self, |
| 570 | udid: &str, |
| 571 | seconds: f64, |
| 572 | limit: usize, |
| 573 | filters: &LogFilters, |
| 574 | ) -> Result<Vec<LogEntry>, AppError> { |
| 575 | let udid = CString::new(udid).map_err(|e| AppError::bad_request(e.to_string()))?; |
| 576 | let json = unsafe { |
| 577 | let mut error = ptr::null_mut(); |
| 578 | let raw = ffi::xcw_native_recent_logs(udid.as_ptr(), seconds, limit, &mut error); |
| 579 | string_from_raw(raw, error)? |
| 580 | }; |
| 581 | let payload: LogsEnvelope = |
| 582 | serde_json::from_str(&json).map_err(|e| AppError::internal(e.to_string()))?; |
| 583 | let mut entries: Vec<LogEntry> = payload |
| 584 | .entries |
| 585 | .into_iter() |
| 586 | .filter(|entry| log_entry_matches(entry, filters)) |
| 587 | .collect(); |
| 588 | if entries.len() > limit { |
| 589 | entries = entries.split_off(entries.len() - limit); |
| 590 | } |
| 591 | Ok(entries) |
| 592 | } |
| 593 | |
| 594 | pub fn accessibility_snapshot( |
| 595 | &self, |
no test coverage detected