add the repository name when connecting

Otherwise, it might be impossible to know which account is connecting when more
than one is syncing.

Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-07-29 05:25:06 +02:00
parent 9aa5afa951
commit 203c28f21f
5 changed files with 27 additions and 18 deletions

View File

@ -25,15 +25,16 @@ from threading import currentThread
import offlineimap
from offlineimap.ui.UIBase import UIBase
protocol = '7.1.0'
protocol = '7.2.0'
class MachineLogFormatter(logging.Formatter):
"""urlencodes any outputted line, to avoid multi-line output"""
def format(s, record):
# Mapping of log levels to historic tag names
severity_map = {
'info': 'msg',
'warning': 'warn',
'info': 'msg',
'warning': 'warn',
}
line = super(MachineLogFormatter, s).format(record)
severity = record.levelname.lower()
@ -101,8 +102,9 @@ class MachineUI(UIBase):
(folder.getname(), folder.getrepository().getname(),
folder.get_saveduidvalidity(), folder.get_uidvalidity()))
def connecting(s, hostname, port):
s._printData(s.logger.info, 'connecting', "%s\n%s"% (hostname, str(port)))
def connecting(s, reposname, hostname, port):
s._printData(s.logger.info, 'connecting', "%s\n%s\nMs"% (hostname,
str(port), reposname))
def syncfolders(s, srcrepos, destrepos):
s._printData(s.logger.info, 'syncfolders', "%s\n%s"% (s.getnicename(srcrepos),

View File

@ -19,9 +19,11 @@ import logging
import sys
import time
from getpass import getpass
from offlineimap import banner
from offlineimap.ui.UIBase import UIBase
class TTYFormatter(logging.Formatter):
"""Specific Formatter that adds thread information to the log output."""

View File

@ -161,9 +161,9 @@ class UIBase(object):
"repo %s")
"""
if msg:
self.logger.error("ERROR: %s\n %s" % (msg, exc))
self.logger.error("ERROR: %s\n %s"% (msg, exc))
else:
self.logger.error("ERROR: %s" % (exc))
self.logger.error("ERROR: %s"% (exc))
instant_traceback = exc_traceback
if not self.debuglist:
@ -181,8 +181,8 @@ class UIBase(object):
if cur_thread in self.threadaccounts:
# was already associated with an old account, update info
self.debug('thread', "Register thread '%s' (previously '%s', now "
"'%s')" % (cur_thread.getName(),
self.getthreadaccount(cur_thread), account))
"'%s')"% (cur_thread.getName(),
self.getthreadaccount(cur_thread), account))
else:
self.debug('thread', "Register new thread '%s' (account '%s')"%
(cur_thread.getName(), account))
@ -193,7 +193,7 @@ class UIBase(object):
if thr in self.threadaccounts:
del self.threadaccounts[thr]
self.debug('thread', "Unregister thread '%s'" % thr.getName())
self.debug('thread', "Unregister thread '%s'"% thr.getName())
def getthreadaccount(self, thr=None):
"""Get Account() for a thread (current if None)
@ -311,7 +311,7 @@ class UIBase(object):
create the application window here."""
pass
def connecting(self, hostname, port):
def connecting(self, reposname, hostname, port):
"""Log 'Establishing connection to'."""
if not self.logger.isEnabledFor(logging.INFO): return
@ -320,13 +320,14 @@ class UIBase(object):
port = "%s"% port if port else ''
if hostname:
displaystr = ' to %s:%s' % (hostname, port)
self.logger.info("Establishing connection%s" % displaystr)
self.logger.info("Establishing connection%s (%s)"%
(displaystr, reposname))
def acct(self, account):
"""Output that we start syncing an account (and start counting)."""
self.acct_startimes[account] = time.time()
self.logger.info("*** Processing account %s" % account)
self.logger.info("*** Processing account %s"% account)
def acctdone(self, account):
"""Output that we finished syncing an account (in which time)."""