summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-10-07 13:40:09 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-10-07 14:00:29 -0400
commitb750263a0537d97f92dad452ef460ee6064af5f3 (patch)
treef1053eae1a750bc3784343eaa57253d95f8dd30b
parentb5d2c2cc4af0919eccfb5489280972fb0a6efa37 (diff)
[bug] fix logging on hooks
-rw-r--r--src/leap/bitmask/hooks.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/leap/bitmask/hooks.py b/src/leap/bitmask/hooks.py
index 79edf6c..fb9771e 100644
--- a/src/leap/bitmask/hooks.py
+++ b/src/leap/bitmask/hooks.py
@@ -20,11 +20,14 @@ Hooks for service composition.
from collections import defaultdict
from twisted.application.service import IService, Service
-from twisted.python import log
+from twisted.logger import Logger
from zope.interface import implementer
+logger = Logger()
+
+
@implementer(IService)
class HookableService(Service):
@@ -44,7 +47,7 @@ class HookableService(Service):
def register_hook(self, name, listener):
if not hasattr(self, 'event_listeners'):
self.event_listeners = defaultdict(list)
- log.msg("Registering hook %s->%s" % (name, listener))
+ logger.debug('registering hook %s->%s' % (name, listener))
self.event_listeners[name].append(listener)
def trigger_hook(self, name, **data):
@@ -53,11 +56,12 @@ class HookableService(Service):
try:
getattr(listener, 'hook_' + name)(**kw)
except AttributeError as exc:
+ logger.failure('Error while triggering hook')
raise RuntimeError(
"Tried to notify a hook, but the listener "
- "service class %s has not defined the "
- "proper method %s" %
- (listener.__class__, 'hook_' + name))
+ "service class %s does not seem to have "
+ "defined the proper method: %s"
+ % (listener.__class__, 'hook_' + name))
if not hasattr(self, 'event_listeners'):
self.event_listeners = defaultdict(list)