blob: 6f2d165cc82dfd649895c0c58f9dffaa5750bcf6 [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 -05006#from gi.repository import GObject
7import gobject
Norman James90baede2015-09-02 20:32:49 -05008import dbus
9import dbus.service
10import dbus.mainloop.glib
Norman James5d78b4d2015-09-05 13:34:34 -050011
Norman James90baede2015-09-02 20:32:49 -050012
13DBUS_NAME = 'org.openbmc.loggers.EventLogger'
14OBJ_NAME = '/org/openbmc/loggers/EventLogger/'+sys.argv[1]
15
16class 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
29if __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 James6f8d0422015-09-14 18:48:00 -050035 mainloop = gobject.MainLoop()
Norman James90baede2015-09-02 20:32:49 -050036
37 print "Running EventLogger"
38 mainloop.run()
39