summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-25 06:47:48 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-25 06:47:48 -0400
commit8d414d7b8fdcad0466f413419d37edc1ebf922d0 (patch)
treefe3b3717bba6ae9fc05a2e8ff78c7a0aeaa3e691 /src/systemd
parent652f6ad4da9918410780ce9f3187f3d3d1f9278c (diff)
journal: Get unit log
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/journal.rs10
-rw-r--r--src/systemd/mod.rs1
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;