summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/logs/safezmqhandler.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-06-19 14:00:28 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2015-06-22 15:52:37 -0300
commit239a0ec845d53b7a0a1af5c27b5eea956ab6459a (patch)
tree1739ad63cb2ca8a3188f307c32b09102ab8f9dd8 /src/leap/bitmask/logs/safezmqhandler.py
parentd75e1395c9ff3ffcb0663122140be393c7ae6b60 (diff)
[feat] handle twisted/logging logs with logbook
Forward Twisted logs to logging and use logbook to handle logging logs. Store the bitmask logs on the config folder.
Diffstat (limited to 'src/leap/bitmask/logs/safezmqhandler.py')
-rw-r--r--src/leap/bitmask/logs/safezmqhandler.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/leap/bitmask/logs/safezmqhandler.py b/src/leap/bitmask/logs/safezmqhandler.py
index 7aac6a6a..4f7aca9b 100644
--- a/src/leap/bitmask/logs/safezmqhandler.py
+++ b/src/leap/bitmask/logs/safezmqhandler.py
@@ -39,6 +39,19 @@ class SafeZMQHandler(ZeroMQHandler):
def __init__(self, uri=None, level=NOTSET, filter=None, bubble=False,
context=None, multi=False):
+ """
+ Safe zmq handler constructor that calls the ZeroMQHandler constructor
+ and does some extra initializations.
+ """
+ # The current `SafeZMQHandler` uses the `ZeroMQHandler` constructor
+ # which creates a socket each time.
+ # The purpose of the `self._sockets` attribute is to prevent cases in
+ # which we use the same logger in different threads. For instance when
+ # we (in the same file) `deferToThread` a method/function, we are using
+ # the same logger/socket without calling get_logger again.
+ # If we want to reuse the socket, we need to rewrite this constructor
+ # instead of calling the ZeroMQHandler's one.
+ # The best approach may be to inherit directly from `logbook.Handler`.
ZeroMQHandler.__init__(self, uri, level, filter, bubble, context,
multi)