Skip to content

Commit

Permalink
Remove log helper and use logging directly
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyheppell committed Jan 29, 2025
1 parent a9d9169 commit 253ce2a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 85 deletions.
5 changes: 2 additions & 3 deletions usp/fetch_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections import OrderedDict
from decimal import Decimal, InvalidOperation
from typing import Optional, Dict, Union

import logging

from .exceptions import SitemapException, SitemapXMLParsingException
from .helpers import (
Expand All @@ -24,7 +24,6 @@
is_http_url,
parse_rfc2822_date,
)
from .log import create_logger
from .objects.page import (
SitemapImage,
SitemapPage,
Expand All @@ -50,7 +49,7 @@
from .web_client.abstract_client import LocalWebClient, NoWebClientException
from .web_client.requests_client import RequestsWebClient

log = create_logger(__name__)
log = logging.getLogger(__name__)


class SitemapFetcher:
Expand Down
4 changes: 2 additions & 2 deletions usp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import gzip as gzip_lib
import html
import logging
import re
import sys
import time
Expand All @@ -12,15 +13,14 @@
from dateutil.parser import isoparse as dateutil_isoparse

from .exceptions import SitemapException, GunzipException, StripURLToHomepageException
from .log import create_logger
from .web_client.abstract_client import (
AbstractWebClient,
AbstractWebClientSuccessResponse,
WebClientErrorResponse,
AbstractWebClientResponse,
)

log = create_logger(__name__)
log = logging.getLogger(__name__)

__URL_REGEX = re.compile(r"^https?://[^\s/$.?#].[^\s]*$", re.IGNORECASE)
"""Regular expression to match HTTP(s) URLs."""
Expand Down
77 changes: 0 additions & 77 deletions usp/log.py

This file was deleted.

4 changes: 2 additions & 2 deletions usp/tree.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Helpers to generate a sitemap tree."""

import logging
from typing import Optional
from .exceptions import SitemapException
from .fetch_parse import SitemapFetcher, SitemapStrParser
from .helpers import is_http_url, strip_url_to_homepage
from .log import create_logger
from .objects.sitemap import (
AbstractSitemap,
InvalidSitemap,
Expand All @@ -13,7 +13,7 @@
)
from .web_client.abstract_client import AbstractWebClient

log = create_logger(__name__)
log = logging.getLogger(__name__)

_UNPUBLISHED_SITEMAP_PATHS = {
"sitemap.xml",
Expand Down
4 changes: 3 additions & 1 deletion usp/web_client/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
)
from usp import __version__

log = logging.getLogger(__name__)


class RequestsWebClientSuccessResponse(AbstractWebClientSuccessResponse):
"""
Expand Down Expand Up @@ -153,7 +155,7 @@ def get(self, url: str) -> AbstractWebClientResponse:
)
else:
message = f"{response.status_code} {response.reason}"
logging.info(f"Response content: {response.text}")
log.info(f"Response content: {response.text}")

if response.status_code in RETRYABLE_HTTP_STATUS_CODES:
return RequestsWebClientErrorResponse(
Expand Down

0 comments on commit 253ce2a

Please sign in to comment.