Norman James | 90baede | 2015-09-02 20:32:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import sys |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 4 | import syslog |
| 5 | import json |
Norman James | 6f8d042 | 2015-09-14 18:48:00 -0500 | [diff] [blame] | 6 | #from gi.repository import GObject |
| 7 | import gobject |
Norman James | 90baede | 2015-09-02 20:32:49 -0500 | [diff] [blame] | 8 | import dbus |
| 9 | import dbus.service |
| 10 | import dbus.mainloop.glib |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 11 | |
Norman James | 90baede | 2015-09-02 20:32:49 -0500 | [diff] [blame] | 12 | |
| 13 | DBUS_NAME = 'org.openbmc.loggers.EventLogger' |
| 14 | OBJ_NAME = '/org/openbmc/loggers/EventLogger/'+sys.argv[1] |
| 15 | |
| 16 | class EventLogger(dbus.service.Object): |
| 17 | def __init__(self,bus,name): |
| 18 | dbus.service.Object.__init__(self,bus,name) |
| 19 | bus = dbus.SessionBus() |
| 20 | syslog.openlog('openbmc') |
| 21 | |
| 22 | bus.add_signal_receiver(self.event_log_signal_handler, |
| 23 | dbus_interface = "org.openbmc.EventLog", signal_name = "EventLog" ) |
| 24 | |
| 25 | ## Signal handler |
| 26 | def event_log_signal_handler(self,message): |
| 27 | syslog.syslog(json.dumps(message)) |
| 28 | |
| 29 | if __name__ == '__main__': |
| 30 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
| 31 | |
| 32 | bus = dbus.SessionBus() |
| 33 | name = dbus.service.BusName(DBUS_NAME, bus) |
| 34 | obj = EventLogger(bus, OBJ_NAME) |
Norman James | 6f8d042 | 2015-09-14 18:48:00 -0500 | [diff] [blame] | 35 | mainloop = gobject.MainLoop() |
Norman James | 90baede | 2015-09-02 20:32:49 -0500 | [diff] [blame] | 36 | |
| 37 | print "Running EventLogger" |
| 38 | mainloop.run() |
| 39 | |