Skip to content

Commit

Permalink
Include launchd.log entries in rage
Browse files Browse the repository at this point in the history
Summary:
Adds entries from launchd.log to `watchmanctl rage` so we can tell which
clients asked launchd to stop the watchman service.

Reviewed By: genevievehelsel

Differential Revision: D50104235

fbshipit-source-id: c1b77df523d90cc575ac5e2fb74754e40b2fea07
  • Loading branch information
Mark Shroyer authored and facebook-github-bot committed Oct 10, 2023
1 parent fd745ff commit c80a3f6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions watchman/cli/src/rage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,31 @@ impl WatchmanRage {
"{}",
cmd!("launchctl", "list", "com.github.facebook.watchman").read()
)?;

writeln!(self.stream, "launchd.log samples:")?;
match File::open("/var/log/com.apple.xpc.launchd/launchd.log") {
Ok(file) => {
let watchman_lines = BufReader::new(file)
.lines()
.filter_map(|result| {
if let Ok(line) = result {
if line.contains("com.github.facebook.watchman") {
return Some(line);
}
}
None
})
.take(40); // Limit log entries printed to avoid flooding the rage

for line in watchman_lines {
writeln!(self.stream, "{}", line)?;
}
}
Err(e) => {
writeln!(self.stream, "Failed to open launchd.log: {}", e)?;
}
}

Ok(())
}

Expand Down

0 comments on commit c80a3f6

Please sign in to comment.