Improved logging for emails

Removed private data from debug export
This commit is contained in:
Ozzieisaacs 2021-01-03 19:27:24 +01:00
parent 760fbbb357
commit a659f2e49d
4 changed files with 18 additions and 5 deletions

View File

@ -275,7 +275,7 @@ class _ConfigSQL(object):
def toDict(self):
storage = {}
for k, v in self.__dict__.items():
if k[0] != '_' or k.endswith("password"):
if k[0] != '_' and not k.endswith("password") and not k.endswith("secret"):
storage[k] = v
return storage

View File

@ -49,6 +49,13 @@ class _Logger(logging.Logger):
else:
self.error(message, stacklevel=2, *args, **kwargs)
def debug_no_auth(self, message, *args, **kwargs):
if message.startswith("send: AUTH"):
self.debug(message[:16], stacklevel=2, *args, **kwargs)
else:
self.debug(message, stacklevel=2, *args, **kwargs)
def get(name=None):
return logging.getLogger(name)

View File

@ -66,9 +66,15 @@ class TaskConvert(CalibreTask):
# if we're sending to kindle after converting, create a one-off task and run it immediately
# todo: figure out how to incorporate this into the progress
try:
worker_thread.add(self.user, TaskEmail(self.settings['subject'], self.results["path"],
filename, self.settings, self.kindle_mail,
self.settings['subject'], self.settings['body'], internal=True))
worker_thread.add(self.user, TaskEmail(self.settings['subject'],
self.results["path"],
filename,
self.settings,
self.kindle_mail,
self.settings['subject'],
self.settings['body'],
internal=True)
)
except Exception as e:
return self._handleError(str(e))

View File

@ -44,7 +44,7 @@ class EmailBase:
def send(self, strg):
"""Send `strg' to the server."""
log.debug('send: %r', strg[:300])
log.debug_no_auth('send: {}'.format(strg[:300]))
if hasattr(self, 'sock') and self.sock:
try:
if self.transferSize: