Skip to content

Commit

Permalink
fix: Stopped the log spamming that happens with multiple instances cr…
Browse files Browse the repository at this point in the history
…eation
  • Loading branch information
D4Vinci committed Dec 16, 2024
1 parent ac95600 commit c282cb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scrapling/engines/toolbelt/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def get_value(cls, content_type: Optional[str], text: Optional[str] = 'test') ->
class Response(Adaptor):
"""This class is returned by all engines as a way to unify response type between different libraries."""

_is_response_result_logged = False # Class-level flag, initialized to False

def __init__(self, url: str, text: str, body: bytes, status: int, reason: str, cookies: Dict, headers: Dict, request_headers: Dict,
encoding: str = 'utf-8', method: str = 'GET', **adaptor_arguments: Dict):
automatch_domain = adaptor_arguments.pop('automatch_domain', None)
Expand All @@ -97,7 +99,9 @@ def __init__(self, url: str, text: str, body: bytes, status: int, reason: str, c
# For back-ward compatibility
self.adaptor = self
# For easier debugging while working from a Python shell
log.info(f'Fetched ({status}) <{method} {url}> (referer: {request_headers.get("referer")})')
if not Response._is_response_result_logged:
log.info(f'Fetched ({status}) <{method} {url}> (referer: {request_headers.get("referer")})')
Response._is_response_result_logged = True

# def __repr__(self):
# return f'<{self.__class__.__name__} [{self.status} {self.reason}]>'
Expand Down

0 comments on commit c282cb3

Please sign in to comment.