Skip to content

Commit 250ceb8

Browse files
committed
Add url to the warning logs
1 parent 573aec3 commit 250ceb8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

scrapy_crawlera/middleware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def _set_crawlera_default_headers(self, request):
226226
]
227227
if all(h.lower() in lower_case_headers for h in self.conflicting_headers):
228228
logging.warn(
229-
'The headers %s are conflicting, X-Crawlera-UA will be ignored. '
230-
'Please check https://doc.scrapinghub.com/crawlera.html for '
231-
'more information'
232-
% str(self.conflicting_headers)
229+
'The headers %s are conflicting on request %s. X-Crawlera-UA '
230+
'will be ignored. Please check https://doc.scrapinghub.com/cr'
231+
'awlera.html for more information'
232+
% (str(self.conflicting_headers), request.url)
233233
)

tests/test_crawlera.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@ def test_crawlera_default_headers_conflicting_headers(self, mock_logger):
413413
self.assertEqual(req.headers['X-Crawlera-Profile'], b'desktop')
414414
mock_logger.warn.assert_called_with(
415415
"The headers ('X-Crawlera-Profile', 'X-Crawlera-UA') are conflictin"
416-
"g, X-Crawlera-UA will be ignored. Please check https://doc.scraping"
417-
"hub.com/crawlera.html for more information"
416+
"g on request http://www.scrapytest.org/other. X-Crawlera-UA will b"
417+
"e ignored. Please check https://doc.scrapinghub.com/crawlera.html "
418+
"for more information"
418419
)
419420

420421
# test it ignores case
@@ -425,6 +426,7 @@ def test_crawlera_default_headers_conflicting_headers(self, mock_logger):
425426
self.assertEqual(req.headers['X-Crawlera-Profile'], b'desktop')
426427
mock_logger.warn.assert_called_with(
427428
"The headers ('X-Crawlera-Profile', 'X-Crawlera-UA') are conflictin"
428-
"g, X-Crawlera-UA will be ignored. Please check https://doc.scraping"
429-
"hub.com/crawlera.html for more information"
429+
"g on request http://www.scrapytest.org/other. X-Crawlera-UA will b"
430+
"e ignored. Please check https://doc.scrapinghub.com/crawlera.html "
431+
"for more information"
430432
)

0 commit comments

Comments
 (0)