|
52 | 52 |
|
53 | 53 | if TYPE_CHECKING: |
54 | 54 | from bs4 import Tag as _bs4_Tag |
| 55 | + |
55 | 56 | from .typing import TYPE_ENCODER |
56 | 57 | from .typing import TYPE_REQUESTS_TIMEOUT |
57 | 58 | from .typing import TYPE_URL_FETCH |
|
86 | 87 |
|
87 | 88 | USE_TLDEXTRACT = True |
88 | 89 |
|
| 90 | + log.info("`tldextract` support enabled.") |
| 91 | +else: |
| 92 | + log.info("`tldextract` support disabled.") |
| 93 | + |
89 | 94 | # ------------------------------------------------------------------------------ |
90 | 95 |
|
91 | 96 |
|
@@ -189,7 +194,7 @@ def is_parsed_valid_url( |
189 | 194 | parsed = parsed.decode() |
190 | 195 | assert isinstance(parsed, ParseResult) |
191 | 196 | if __debug__: |
192 | | - log.debug("is_parsed_valid_url = %s", parsed) |
| 197 | + log.debug("is_parsed_valid_url(parsed=%s", parsed) |
193 | 198 | if not all((parsed.scheme, parsed.netloc)): |
194 | 199 | if __debug__: |
195 | 200 | log.debug(" FALSE - missing `scheme` or `netloc`") |
@@ -528,6 +533,9 @@ def log( |
528 | 533 | logger: Callable[..., None] = log.error, |
529 | 534 | ) -> None: |
530 | 535 | """ |
| 536 | + Invoked to log troubleshooting information when an error is encountered. |
| 537 | + By default this goes to `log.error`. |
| 538 | +
|
531 | 539 | :param prefix: Prefix for logging, defaults to "ResponseHistory" |
532 | 540 | :type prefix: str |
533 | 541 | :param logger: default `log.error` |
@@ -1476,7 +1484,9 @@ def make_soup(self, html, **kwargs_bs): |
1476 | 1484 | doc = BeautifulSoup(html, "lxml", **kwargs_bs) |
1477 | 1485 | except Exception as exc: # noqa: F841 |
1478 | 1486 | if __debug__: |
1479 | | - log.debug("`BeautifulSoup` could not parse with `lxml`") |
| 1487 | + log.error( |
| 1488 | + "`BeautifulSoup` could not parse with `lxml`; attempting `html.parser`" |
| 1489 | + ) |
1480 | 1490 | doc = BeautifulSoup(html, "html.parser", **kwargs_bs) |
1481 | 1491 | return doc |
1482 | 1492 |
|
@@ -1566,7 +1576,7 @@ def parse( |
1566 | 1576 | pass |
1567 | 1577 | except Exception as exc: |
1568 | 1578 | if __debug__: |
1569 | | - log.debug("Ran into a serious error parsing `og`: %s", exc) |
| 1579 | + log.error("Ran into a serious error parsing `og`: %s", exc) |
1570 | 1580 | pass |
1571 | 1581 |
|
1572 | 1582 | twitters = doc_searchpath.find_all("meta", attrs={"name": RE_prefix_twitter}) |
|
0 commit comments