Skip to content

Commit

Permalink
Add CLI arg to dump the last pre-reboot logs (#46)
Browse files Browse the repository at this point in the history
This is passed through to `logcat` and has the same argument signature
(`-L`, `--last`).

Co-authored-by: Simon B. Gasse <[email protected]>
  • Loading branch information
sgasse and sgasse authored Feb 13, 2023
1 parent f582ce4 commit 2104a5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ pub fn cli() -> App<'static, 'static> {
.takes_value(true)
.multiple(true)
.help( "Read from file instead of command. Use 'serial://COM0@115200,8N1 or similiar for reading a serial port"))
.arg(Arg::with_name("last")
.short("L")
.long("last")
.conflicts_with_all(&["input", "COMMAND"])
.help("Dump the logs prior to the last reboot"))
.arg(Arg::with_name("level")
.short("l")
.long("level")
Expand Down
5 changes: 5 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ pub fn logcat(args: &ArgMatches) -> Result<LogStream, Error> {
respawn = false;
}

if args.is_present("last") {
cmd.push("--last".into());
respawn = false;
}

for buffer in args
.values_of("buffer")
.map(|m| m.map(ToOwned::to_owned).collect::<Vec<String>>())
Expand Down

0 comments on commit 2104a5a

Please sign in to comment.