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

Function read_log_stream

packages/server/src/logs.rs:172–195  ·  view source on GitHub ↗
(
    mut child: Child,
    stdout: ChildStdout,
    state: Arc<LogStreamState>,
)

Source from the content-addressed store, hash-verified

170}
171
172async fn read_log_stream(
173 mut child: Child,
174 stdout: ChildStdout,
175 state: Arc<LogStreamState>,
176) -> Result<(), String> {
177 let mut lines = BufReader::new(stdout).lines();
178 while let Some(line) = lines.next_line().await.map_err(|error| error.to_string())? {
179 let Some(entry) = parse_log_entry(&line) else {
180 continue;
181 };
182
183 let mut entries = state.entries.lock().await;
184 entries.push_back(entry);
185 while entries.len() > MAX_LOG_ENTRIES {
186 entries.pop_front();
187 }
188 }
189
190 if matches!(child.try_wait(), Ok(None)) {
191 let _ = child.kill().await;
192 }
193 let _ = child.wait().await;
194 Ok(())
195}
196
197fn parse_log_entry(line: &str) -> Option<LogEntry> {
198 let trimmed = line.trim();

Callers 1

ensure_startedMethod · 0.85

Calls 2

parse_log_entryFunction · 0.85
waitMethod · 0.80

Tested by

no test coverage detected