diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2013-02-15 09:32:08 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2013-02-26 12:03:43 +0100 |
commit | 91b79834c7d526e95d0c3720af540a2ceafcd9ff (patch) | |
tree | baf1a6b2cc07a0bc9543f165061586dd61cddf45 /test | |
parent | 5ae059affcd72987b9881fc2421140258cdb84f8 (diff) |
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.
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-dbus.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/test-dbus.py b/test/test-dbus.py index ecabd02b..e151deee 100755 --- a/test/test-dbus.py +++ b/test/test-dbus.py @@ -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" |