Skip to content

Commit 35e1088

Browse files
committed
Don't log to the root logger
1 parent 5b85562 commit 35e1088

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

pytest_reportportal/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
except ImportError:
1717
PYTEST_HAS_LOGGING_PLUGIN = False
1818

19+
log = logging.getLogger(__name__)
20+
1921

2022
def is_master(config):
2123
"""
@@ -109,7 +111,7 @@ def pytest_unconfigure(config):
109111
reporter = config._reporter
110112
del config._reporter
111113
config.pluginmanager.unregister(reporter)
112-
logging.debug('RP is unconfigured')
114+
log.debug('RP is unconfigured')
113115

114116

115117
def pytest_addoption(parser):

pytest_reportportal/rp_logging.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def filter(self, record):
7373
# Don't send reportportal_client logs.
7474
# Specially because we'll hit a max recursion issue
7575
return False
76+
if record.name.startswith('pytest_reportportal'):
77+
# Don't send pytest_reportportal logs.
78+
return False
7679
return True
7780

7881
def emit(self, record):

pytest_reportportal/service.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from reportportal_client import ReportPortalServiceAsync
1111

12+
log = logging.getLogger(__name__)
13+
1214

1315
def timestamp():
1416
return str(int(time() * 1000))
@@ -39,8 +41,8 @@ def init_service(self, endpoint, project, uuid, log_batch_size,
3941
if self.RP is None:
4042
self.ignore_errors = ignore_errors
4143
self.ignored_tags = ignored_tags
42-
logging.debug('ReportPortal - Init service: endpoint=%s, '
43-
'project=%s, uuid=%s', endpoint, project, uuid)
44+
log.debug('ReportPortal - Init service: endpoint=%s, '
45+
'project=%s, uuid=%s', endpoint, project, uuid)
4446
self.RP = ReportPortalServiceAsync(
4547
endpoint=endpoint,
4648
project=project,
@@ -49,7 +51,7 @@ def init_service(self, endpoint, project, uuid, log_batch_size,
4951
log_batch_size=log_batch_size
5052
)
5153
else:
52-
logging.debug('The pytest is already initialized')
54+
log.debug('The pytest is already initialized')
5355
return self.RP
5456

5557
def async_error_handler(self, exc_info):
@@ -84,11 +86,9 @@ def start_launch(
8486
'mode': mode,
8587
'tags': tags
8688
}
87-
logging.debug('ReportPortal - Start launch: '
88-
'request_body=%s', sl_pt)
89+
log.debug('ReportPortal - Start launch: equest_body=%s', sl_pt)
8990
req_data = self.RP.start_launch(**sl_pt)
90-
logging.debug('ReportPortal - Launch started: '
91-
'response_body=%s', req_data)
91+
log.debug('ReportPortal - Launch started: response_body=%s', req_data)
9292

9393
def start_pytest_item(self, test_item=None):
9494
self._stop_if_necessary()
@@ -103,8 +103,7 @@ def start_pytest_item(self, test_item=None):
103103
'item_type': 'STEP'
104104
}
105105

106-
logging.debug('ReportPortal - Start TestItem: '
107-
'request_body=%s', start_rq)
106+
log.debug('ReportPortal - Start TestItem: request_body=%s', start_rq)
108107
self.RP.start_test_item(**start_rq)
109108

110109
def _get_tags(self, item):
@@ -124,8 +123,7 @@ def finish_pytest_item(self, status, issue=None):
124123
'issue': issue
125124
}
126125

127-
logging.debug('ReportPortal - Finish TestItem: '
128-
'request_body=%s', fta_rq)
126+
log.debug('ReportPortal - Finish TestItem: request_body=%s', fta_rq)
129127
self.RP.finish_test_item(**fta_rq)
130128

131129
def finish_launch(self, launch=None, status='rp_launch'):
@@ -138,7 +136,7 @@ def finish_launch(self, launch=None, status='rp_launch'):
138136
'end_time': timestamp(),
139137
'status': status
140138
}
141-
logging.debug('ReportPortal - Finish launch: request_body=%s', fl_rq)
139+
log.debug('ReportPortal - Finish launch: request_body=%s', fl_rq)
142140
self.RP.finish_launch(**fl_rq)
143141

144142
def post_log(self, message, loglevel='INFO', attachment=None):
@@ -147,8 +145,8 @@ def post_log(self, message, loglevel='INFO', attachment=None):
147145
return
148146

149147
if loglevel not in self._loglevels:
150-
logging.warning('Incorrect loglevel = %s. Force set to INFO. '
151-
'Available levels: %s.', loglevel, self._loglevels)
148+
log.warning('Incorrect loglevel = %s. Force set to INFO. '
149+
'Available levels: %s.', loglevel, self._loglevels)
152150
loglevel = 'INFO'
153151

154152
sl_rq = {

0 commit comments

Comments
 (0)