blob: 0c4fcfc1dbbb98316d2cbd25363c07fa23540e8a [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
Norman James6f8d0422015-09-14 18:48:00 -05006import gobject
Norman James90baede2015-09-02 20:32:49 -05007import dbus
8import dbus.service
9import dbus.mainloop.glib
Norman James32e74e22015-09-15 21:28:06 -050010import Openbmc
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,
Norman James32e74e22015-09-15 21:28:06 -050022 dbus_interface = "org.openbmc.EventLog",
23 signal_name = "EventLog",
24 path_keyword='path')
Norman James90baede2015-09-02 20:32:49 -050025
26 ## Signal handler
Norman James32e74e22015-09-15 21:28:06 -050027 def event_log_signal_handler(self,e_type,msg,path = None):
28 message = {}
29 message['object_path'] = path
30 message['e_type'] = Openbmc.EVENT_TYPES[int(e_type)]
31 message['message'] = msg
Norman James90baede2015-09-02 20:32:49 -050032 syslog.syslog(json.dumps(message))
33
34if __name__ == '__main__':
35 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
36
37 bus = dbus.SessionBus()
38 name = dbus.service.BusName(DBUS_NAME, bus)
39 obj = EventLogger(bus, OBJ_NAME)
Norman James6f8d0422015-09-14 18:48:00 -050040 mainloop = gobject.MainLoop()
Norman James90baede2015-09-02 20:32:49 -050041
42 print "Running EventLogger"
43 mainloop.run()
44