Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve voltage warning lines in TinyPilot logs (#1544)
Resolves #1495 Parses the output of `journalctl` into a simple “yes” or “no” result. If the result is “yes”, the latest voltage warning is also included in the output. ## Parsing the output of `journalctl` I initially considered piping the output of `journalctl` into `grep` for readability, but getting the correct exit code as well as just the latest voltage warning was quite awkward with this approach. I therefore settled on using just the filtering and output options that are built into `journalctl`: - The `-q` argument is used to suppress the unwanted `journalctl` header text. - The `-r` argument causes `journalctl` to output from newest to oldest. - The `-n 1` argument causes `journalctl` to stop after outputting a single line. - The `-g "voltage"` argument limits output to only lines that contain the word “voltage”. The end result of this combination of arguments is that `journalctl` will efficiently output only the most recent voltage warning. In addition, the exit status of the command reflects whether or not any matching lines were found, which allows for a simple `if <command>` test to be used. Short arguments were used for consistency with the majority of the rest of the `collect-debug-logs` script. <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1544"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a>
- Loading branch information