Make logging less intrusive

This commit is contained in:
László Károlyi 2020-11-19 14:26:52 +01:00
parent 877b301ed6
commit d3ec33f878
Signed by: karolyi
GPG Key ID: 2DCAF25E55735BFE
6 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,7 @@
0.2.11:
- Make emitting logs off per default, observer the passed `debug` parameter
- Set updater log level to debug
0.2.10:
- Adding STARTTLS handling
- Use EHLO instead of HELO

View File

@ -41,7 +41,7 @@ Basic usage::
:code:`use_blacklist`: use the blacklist of domains downloaded from https://github.com/martenson/disposable-email-domains
:code:`debug`: emit debug messages while checking email
:code:`debug`: emit debug/warning messages while checking email
The function :code:`validate_email_or_fail()` works exactly like :code:`validate_email`, except that it raises an exception in the case of validation failure instead of returning :code:`False`.

View File

@ -56,7 +56,7 @@ class BuildPyCommand(build_py):
setup(
name='py3-validate-email',
version='0.2.10',
version='0.2.11',
packages=find_packages(exclude=['tests']),
install_requires=['dnspython~=2.0', 'idna~=2.10', 'filelock~=3.0'],
author='László Károlyi',

View File

@ -62,7 +62,6 @@ def _smtp_ehlo_tls(smtp: SMTP, helo_host: str):
smtp.starttls()
code, message = smtp.ehlo(name=helo_host)
except SMTPNotSupportedError as exc:
print('XXX', exc)
# The server does not support the STARTTLS extension
pass
except RuntimeError:

View File

@ -135,7 +135,7 @@ def update_builtin_blacklist(
Update and reload the built-in blacklist. Return the `Thread` used
to do the background update, so it can be `join()`-ed.
"""
LOGGER.info(msg='Starting optional update of built-in blacklist.')
LOGGER.debug(msg='Starting optional update of built-in blacklist.')
blacklist_updater = BlacklistUpdater()
kwargs = dict(force=force, callback=callback)
if not background:

View File

@ -40,7 +40,8 @@ def validate_email_or_fail(
dns_timeout=dns_timeout, debug=debug)
def validate_email(email_address: str, *args, **kwargs):
def validate_email(
email_address: str, *args, **kwargs):
"""
Return `True` or `False` depending if the email address exists
or/and can be delivered.
@ -51,5 +52,6 @@ def validate_email(email_address: str, *args, **kwargs):
return validate_email_or_fail(email_address, *args, **kwargs)
except EmailValidationError as error:
message = f'Validation for {email_address!r} failed: {error}'
LOGGER.warning(msg=message)
if kwargs.get('debug'):
LOGGER.warning(msg=message)
return False