diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-05-25 06:47:48 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-05-25 06:47:48 -0400 |
commit | 8d414d7b8fdcad0466f413419d37edc1ebf922d0 (patch) | |
tree | fe3b3717bba6ae9fc05a2e8ff78c7a0aeaa3e691 /src/systemd | |
parent | 652f6ad4da9918410780ce9f3187f3d3d1f9278c (diff) |
journal: Get unit log
Diffstat (limited to 'src/systemd')
-rw-r--r-- | src/systemd/journal.rs | 10 | ||||
-rw-r--r-- | src/systemd/mod.rs | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/systemd/journal.rs b/src/systemd/journal.rs new file mode 100644 index 0000000..86791ab --- /dev/null +++ b/src/systemd/journal.rs @@ -0,0 +1,10 @@ +use std::process::Command; +use std::io; + +pub fn get_log(unit: &str, lines: i32) -> io::Result<String> { + let status = try!(Command::new("journalctl") + .args(&["-u", unit, + "-n", &lines.to_string()]) + .output()); + Ok(String::from_utf8_lossy(&status.stdout).into_owned()) +} diff --git a/src/systemd/mod.rs b/src/systemd/mod.rs index a5acbce..bc1a9a1 100644 --- a/src/systemd/mod.rs +++ b/src/systemd/mod.rs @@ -1 +1,2 @@ pub mod unit; +pub mod journal; |