D-Bus testing: improved logging
Log message now contain time stamps. A NullLogging class mimics the Logging interface and can be used instead of that to suppress logging. As a side effect of turning the log() method into a wrapper, the D-Bus signal is now called "log2", which makes it possible to search for it case-insensitively in emacs without finding the LogOutput signal.
This commit is contained in:
parent
5ae059affc
commit
91b79834c7
|
@ -131,18 +131,29 @@ loop = gobject.MainLoop()
|
|||
class Logging(dbus.service.Object):
|
||||
def __init__(self):
|
||||
dbus.service.Object.__init__(self, bus, '/test/dbus/py')
|
||||
self.start = time.time()
|
||||
|
||||
@dbus.service.signal(dbus_interface='t.d.p',
|
||||
signature='s')
|
||||
def log(self, str):
|
||||
def log2(self, str):
|
||||
if debugger or os.environ.get("TEST_DBUS_VERBOSE", False):
|
||||
print str
|
||||
pass
|
||||
|
||||
def log(self, str):
|
||||
now = time.time()
|
||||
self.log2(('%.3fs: ' % (now - self.start)) + str)
|
||||
|
||||
def printf(self, format, *args):
|
||||
self.log(format % args)
|
||||
logging = Logging()
|
||||
|
||||
class NullLogging:
|
||||
def log(self, str):
|
||||
pass
|
||||
def printf(self, format, *args):
|
||||
pass
|
||||
|
||||
# Bluez default adapter
|
||||
bt_adaptor = "/org/bluez/1036/hci0"
|
||||
|
||||
|
|
Loading…
Reference in New Issue