-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from logging import INFO | ||
|
||
from scrapy.exceptions import DropItem | ||
from scrapy.logformatter import LogFormatter | ||
|
||
|
||
class InfoDropItem(DropItem): | ||
"""DropItem subclass for items that should be dropped with an INFO message | ||
(instead of the default WARNING message).""" | ||
|
||
|
||
class ZyteLogFormatter(LogFormatter): | ||
def dropped(self, item, exception, response, spider): | ||
data = super().dropped(item, exception, response, spider) | ||
if isinstance(exception, InfoDropItem): | ||
data["level"] = INFO | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters