1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

make _logid a public argument, critique from @flub accepted

This commit is contained in:
holger krekel 2018-09-09 13:51:54 +02:00
parent 49040f4e92
commit 25a2cdb301
2 changed files with 9 additions and 9 deletions

View file

@ -34,7 +34,7 @@ def acfactory(pytestconfig, tmpdir, request):
def get_offline_account(self): def get_offline_account(self):
self.offline_count += 1 self.offline_count += 1
tmpdb = tmpdir.join("offlinedb%d" % self.offline_count) tmpdb = tmpdir.join("offlinedb%d" % self.offline_count)
ac = Account(tmpdb.strpath, _logid="ac{}".format(self.offline_count)) ac = Account(tmpdb.strpath, logid="ac{}".format(self.offline_count))
ac._evlogger.set_timeout(2) ac._evlogger.set_timeout(2)
return ac return ac
@ -42,7 +42,7 @@ def acfactory(pytestconfig, tmpdir, request):
self.live_count += 1 self.live_count += 1
configdict = self.configlist.pop(0) configdict = self.configlist.pop(0)
tmpdb = tmpdir.join("livedb%d" % self.live_count) tmpdb = tmpdir.join("livedb%d" % self.live_count)
ac = Account(tmpdb.strpath, _logid="ac{}".format(self.live_count)) ac = Account(tmpdb.strpath, logid="ac{}".format(self.live_count))
ac._evlogger.set_timeout(10) ac._evlogger.set_timeout(10)
ac.set_config(**configdict) ac.set_config(**configdict)
if started: if started:

View file

@ -37,13 +37,13 @@ class EventHandler:
class EventLogger: class EventLogger:
def __init__(self, dc_context, _logid=None, debug=True): def __init__(self, dc_context, logid=None, debug=True):
self.dc_context = dc_context self.dc_context = dc_context
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.dc_context).strip(">").split()[-1]
self._logid = _logid self.logid = logid
self._timeout = None self._timeout = None
def __call__(self, evt_name, data1, data2): def __call__(self, evt_name, data1, data2):
@ -72,7 +72,7 @@ class EventLogger:
t = threading.currentThread() t = threading.currentThread()
tname = getattr(t, "name", t) tname = getattr(t, "name", t)
print("[{}-{}] {}({!r},{!r})".format( print("[{}-{}] {}({!r},{!r})".format(
tname, self._logid, evt_name, data1, data2)) tname, self.logid, evt_name, data1, data2))
class Contact: class Contact:
@ -140,7 +140,7 @@ class Message:
class Account: class Account:
def __init__(self, db_path, _logid=None): def __init__(self, db_path, logid=None):
self.dc_context = ctx = capi.lib.dc_context_new( self.dc_context = ctx = capi.lib.dc_context_new(
capi.lib.py_dc_callback, capi.lib.py_dc_callback,
capi.ffi.NULL, capi.ffi.NULL) capi.ffi.NULL, capi.ffi.NULL)
@ -148,7 +148,7 @@ class Account:
db_path = db_path.encode("utf8") db_path = db_path.encode("utf8")
capi.lib.dc_open(ctx, db_path, capi.ffi.NULL) capi.lib.dc_open(ctx, db_path, capi.ffi.NULL)
self._evhandler = EventHandler(self.dc_context) self._evhandler = EventHandler(self.dc_context)
self._evlogger = EventLogger(self.dc_context, _logid) self._evlogger = EventLogger(self.dc_context, logid)
self._threads = IOThreads(self.dc_context) self._threads = IOThreads(self.dc_context)
def set_config(self, **kwargs): def set_config(self, **kwargs):