mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
fix eventlogger
This commit is contained in:
@@ -38,7 +38,7 @@ class Account(object):
|
|||||||
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)),
|
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)),
|
||||||
_destroy_dc_context,
|
_destroy_dc_context,
|
||||||
)
|
)
|
||||||
self._evlogger = EventLogger(self._dc_context, logid, debug)
|
self._evlogger = EventLogger(self, logid, debug)
|
||||||
self._threads = IOThreads(self._dc_context, self._evlogger._log_event)
|
self._threads = IOThreads(self._dc_context, self._evlogger._log_event)
|
||||||
|
|
||||||
# register event call back and initialize plugin system
|
# register event call back and initialize plugin system
|
||||||
|
|||||||
@@ -8,20 +8,21 @@ from .hookspec import hookimpl
|
|||||||
class EventLogger:
|
class EventLogger:
|
||||||
_loglock = threading.RLock()
|
_loglock = threading.RLock()
|
||||||
|
|
||||||
def __init__(self, dc_context, logid=None, debug=True):
|
def __init__(self, account, logid=None, debug=True):
|
||||||
self._dc_context = dc_context
|
self.account = account
|
||||||
self._event_queue = Queue()
|
self._event_queue = Queue()
|
||||||
self._debug = debug
|
self._debug = debug
|
||||||
if logid is None:
|
if logid is None:
|
||||||
logid = str(self._dc_context).strip(">").split()[-1]
|
logid = str(self.account._dc_context).strip(">").split()[-1]
|
||||||
self.logid = logid
|
self.logid = logid
|
||||||
self._timeout = None
|
self._timeout = None
|
||||||
self.init_time = time.time()
|
self.init_time = time.time()
|
||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def process_low_level_event(self, event_name, data1, data2):
|
def process_low_level_event(self, account, event_name, data1, data2):
|
||||||
self._log_event(event_name, data1, data2)
|
if self.account == account:
|
||||||
self._event_queue.put((event_name, data1, data2))
|
self._log_event(event_name, data1, data2)
|
||||||
|
self._event_queue.put((event_name, data1, data2))
|
||||||
|
|
||||||
def set_timeout(self, timeout):
|
def set_timeout(self, timeout):
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
|
|||||||
Reference in New Issue
Block a user