Improve logging options
Issue our own log messages independently of the "debug" parameter, so a user can activate our log messages through Python's standard logger config features, while still having dsabled smtplib's debug messages, which are very verbose and always go to stderr. Change the log output for failed and ambiguous verifications from "warning" to "info" as this is a normal function of the library and not something that would require attention. Also this makes sure that no log output is generated if logging is not configured at all (default is to only display warning and above).
This commit is contained in:
parent
c6c3c18ebe
commit
a0f1cd1b04
|
@ -212,8 +212,7 @@ class _SMTPChecker(SMTP):
|
|||
return `True`, else raise exceptions described in `mx_check`.
|
||||
"""
|
||||
for host in hosts:
|
||||
if self.debuglevel > 0:
|
||||
LOGGER.debug(msg=f'Trying {host} ...')
|
||||
LOGGER.debug(msg=f'Trying {host} ...')
|
||||
if self._check_one(host=host):
|
||||
return True
|
||||
# Raise appropriate exceptions when necessary
|
||||
|
|
|
@ -63,12 +63,8 @@ def validate_email(email_address: str, *args, **kwargs):
|
|||
try:
|
||||
return validate_email_or_fail(email_address, *args, **kwargs)
|
||||
except SMTPTemporaryError as error:
|
||||
message = f'Validation for {email_address!r} ambigious: {error}'
|
||||
if kwargs.get('debug'):
|
||||
LOGGER.warning(msg=message)
|
||||
LOGGER.info(msg=f'Validation for {email_address!r} ambigious: {error}')
|
||||
return
|
||||
except EmailValidationError as error:
|
||||
message = f'Validation for {email_address!r} failed: {error}'
|
||||
if kwargs.get('debug'):
|
||||
LOGGER.warning(msg=message)
|
||||
LOGGER.info(msg=f'Validation for {email_address!r} failed: {error}')
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue