diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-05-16 03:55:52 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-16 03:55:52 +0200 |
commit | c1b94fda55e6e29e388a30f846b62650b5e60f7e (patch) | |
tree | 7fbeecae47fc92d9afa9d424ba863b0ccb75fb4a /systemctl.vala | |
parent | cb8a8f78a11cedb8cba1abfa9a63b0d3ea8eef93 (diff) |
systemctl: log whenever a unit/job changes
Diffstat (limited to 'systemctl.vala')
-rw-r--r-- | systemctl.vala | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/systemctl.vala b/systemctl.vala index ddbede94b6..821be5a4f8 100644 --- a/systemctl.vala +++ b/systemctl.vala @@ -24,6 +24,7 @@ static string type = null; static bool all = false; static bool replace = false; static bool session = false; +static Connection bus = null; public static int job_info_compare(void* key1, void* key2) { Manager.JobInfo *j1 = (Manager.JobInfo*) key1; @@ -43,12 +44,40 @@ public static int unit_info_compare(void* key1, void* key2) { return Posix.strcmp(u1->id, u2->id); } +public void on_unit_changed(Unit u) { + stdout.printf("Unit %s changed.\n", u.id); +} + public void on_unit_new(string id, ObjectPath path) { stdout.printf("Unit %s added.\n", id); + + Unit u = bus.get_object( + "org.freedesktop.systemd1", + path, + "org.freedesktop.systemd1.Unit") as Unit; + + u.changed += on_unit_changed; + + /* FIXME: We leak memory here */ + u.ref(); +} + +public void on_job_changed(Job j) { + stdout.printf("Job %u changed.\n", j.id); } public void on_job_new(uint32 id, ObjectPath path) { stdout.printf("Job %u added.\n", id); + + Job j = bus.get_object( + "org.freedesktop.systemd1", + path, + "org.freedesktop.systemd1.Job") as Job; + + j.changed += on_job_changed; + + /* FIXME: We leak memory here */ + j.ref(); } public void on_unit_removed(string id, ObjectPath path) { @@ -100,7 +129,7 @@ int main (string[] args) { } try { - Connection bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM); + bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM); Manager manager = bus.get_object ( "org.freedesktop.systemd1", |