blob: 3701d28f6871812aa736641fdf22a7aa015e1d2a [file] [log] [blame]
Norman James90baede2015-09-02 20:32:49 -05001#!/usr/bin/env python
2
3import sys
Norman James5d78b4d2015-09-05 13:34:34 -05004import syslog
5import json
6from gi.repository import GObject
Norman James90baede2015-09-02 20:32:49 -05007import dbus
8import dbus.service
9import dbus.mainloop.glib
Norman James5d78b4d2015-09-05 13:34:34 -050010
Norman James90baede2015-09-02 20:32:49 -050011
12DBUS_NAME = 'org.openbmc.loggers.EventLogger'
13OBJ_NAME = '/org/openbmc/loggers/EventLogger/'+sys.argv[1]
14
15class EventLogger(dbus.service.Object):
16 def __init__(self,bus,name):
17 dbus.service.Object.__init__(self,bus,name)
18 bus = dbus.SessionBus()
19 syslog.openlog('openbmc')
20
21 bus.add_signal_receiver(self.event_log_signal_handler,
22 dbus_interface = "org.openbmc.EventLog", signal_name = "EventLog" )
23
24 ## Signal handler
25 def event_log_signal_handler(self,message):
26 syslog.syslog(json.dumps(message))
27
28if __name__ == '__main__':
29 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
30
31 bus = dbus.SessionBus()
32 name = dbus.service.BusName(DBUS_NAME, bus)
33 obj = EventLogger(bus, OBJ_NAME)
Norman James5d78b4d2015-09-05 13:34:34 -050034 mainloop = GObject.MainLoop()
Norman James90baede2015-09-02 20:32:49 -050035
36 print "Running EventLogger"
37 mainloop.run()
38