Skip to content

Commit

Permalink
Filter urllib3 messages correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
iivanou authored Apr 1, 2021
1 parent ef8a635 commit e501b45
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pytest_reportportal/rp_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import logging
from contextlib import contextmanager
from functools import wraps

from six import PY2
from six.moves.urllib.parse import urlparse


class RPLogger(logging.getLoggerClass()):
Expand Down Expand Up @@ -102,21 +104,21 @@ def __init__(self, py_test_service,
self.endpoint = endpoint

def filter(self, record):
"""
Filter the reportportal_client messages.
"""Filter specific records to avoid sending those to RP.
:param record: a log record to filter
:return: bool - False if it is an agent or client log and
'filter_client_logs' attribute is True, other way always True
:param record: A log record to be filtered
:return: False if the given record does no fit for sending
to RP, otherwise True.
"""
if not self.filter_client_logs:
return True
if record.name.startswith(self.ignored_record_names):
return False
if record.name == 'urllib3.connectionpool':
if record.name.startswith('urllib3.connectionpool'):
# Filter the reportportal_client requests instance
# urllib3 usage
if self.endpoint.rstrip('/') in self.format(record):
hostname = urlparse(self.endpoint).hostname
if hostname in self.format(record):
return False
return True

Expand Down

0 comments on commit e501b45

Please sign in to comment.