MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / performance_log_events

Function performance_log_events

packages/server/src/api/routes.rs:2087–2128  ·  view source on GitHub ↗
(
    state: &AppState,
    udid: &str,
    snapshot: &crate::performance::SimulatorPerformanceSnapshot,
)

Source from the content-addressed store, hash-verified

2085}
2086
2087async fn performance_log_events(
2088 state: &AppState,
2089 udid: &str,
2090 snapshot: &crate::performance::SimulatorPerformanceSnapshot,
2091) -> Vec<Value> {
2092 let Some(current) = snapshot.current.as_ref() else {
2093 return Vec::new();
2094 };
2095 let process_name = snapshot
2096 .processes
2097 .iter()
2098 .find(|process| process.pid == current.pid)
2099 .map(|process| process.process.as_str())
2100 .unwrap_or("");
2101 let filters = LogFilters::new(Vec::new(), Vec::new(), String::new());
2102 if state.logs.ensure_started(udid).await.is_err() {
2103 return Vec::new();
2104 }
2105 state
2106 .logs
2107 .snapshot(udid, &filters, 800)
2108 .await
2109 .into_iter()
2110 .rev()
2111 .filter(|entry| performance_log_entry_matches(entry, current.pid, process_name))
2112 .take(12)
2113 .map(|entry| {
2114 json_value!({
2115 "timestamp": entry.timestamp,
2116 "level": entry.level,
2117 "process": entry.process,
2118 "pid": entry.pid,
2119 "subsystem": entry.subsystem,
2120 "category": entry.category,
2121 "message": entry.message,
2122 })
2123 })
2124 .collect::<Vec<_>>()
2125 .into_iter()
2126 .rev()
2127 .collect()
2128}
2129
2130fn performance_log_entry_matches(
2131 entry: &crate::native::bridge::LogEntry,

Callers 1

Calls 4

as_strMethod · 0.45
ensure_startedMethod · 0.45
snapshotMethod · 0.45

Tested by

no test coverage detected