scrapy / scrapy

Scrapy, a fast high-level web crawling & scraping framework for Python.
https://scrapy.org
BSD 3-Clause "New" or "Revised" License
51.16k stars 10.35k forks source link

issue #6323: add SpiderLoggerAdapter, change Spider.logger to return SpiderLoggerAdapter #6324

Closed bloodforcream closed 5 days ago

bloodforcream commented 3 weeks ago

fixes #6323

SpiderLoggerAdapter prioritizes self.extra over logged extra so it works as it worked before. spider in extra will always be self

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.88%. Comparing base (1d11ea3) to head (bd43233). Report is 46 commits behind head on master.

:exclamation: Current head bd43233 differs from pull request most recent head 1320e2a. Consider uploading reports for the commit 1320e2a to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #6324 +/- ## ========================================== + Coverage 83.92% 88.88% +4.95% ========================================== Files 161 162 +1 Lines 11972 11981 +9 Branches 1865 1930 +65 ========================================== + Hits 10048 10649 +601 + Misses 1588 980 -608 - Partials 336 352 +16 ``` | [Files](https://app.codecov.io/gh/scrapy/scrapy/pull/6324?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scrapy) | Coverage Δ | | |---|---|---| | [scrapy/spiders/\_\_init\_\_.py](https://app.codecov.io/gh/scrapy/scrapy/pull/6324?src=pr&el=tree&filepath=scrapy%2Fspiders%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scrapy#diff-c2NyYXB5L3NwaWRlcnMvX19pbml0X18ucHk=) | `93.84% <100.00%> (+0.09%)` | :arrow_up: | | [scrapy/utils/spider\_logger\_adapter.py](https://app.codecov.io/gh/scrapy/scrapy/pull/6324?src=pr&el=tree&filepath=scrapy%2Futils%2Fspider_logger_adapter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scrapy#diff-c2NyYXB5L3V0aWxzL3NwaWRlcl9sb2dnZXJfYWRhcHRlci5weQ==) | `100.00% <100.00%> (ø)` | | ... and [26 files with indirect coverage changes](https://app.codecov.io/gh/scrapy/scrapy/pull/6324/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scrapy)
wRAR commented 1 week ago

Is it possible to add a test that checks that the Spider logging methods work as expected?

bloodforcream commented 1 week ago

Is it possible to add a test that checks that the Spider logging methods work as expected?

Do you mean a test that's making sure general logging messages(not "extra") of Spider work as expected? I'll try to code them today/tomorrow

bloodforcream commented 1 week ago

Added more tests