From 239a0ec845d53b7a0a1af5c27b5eea956ab6459a Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 19 Jun 2015 14:00:28 -0300 Subject: [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. --- src/leap/bitmask/logs/safezmqhandler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/leap/bitmask/logs/safezmqhandler.py') 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) -- cgit v1.2.3