Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Rename LogFormatter.error to item_error

Eugenio Lacuesta7a7d13b1122d
diff --git a/scrapy/core/scraper.py b/scrapy/core/scraper.py
index db463f989..c5bb48ea6 100644
--- a/scrapy/core/scraper.py
+++ b/scrapy/core/scraper.py
@@ -231,7 +231,7 @@ class Scraper(object):
signal=signals.item_dropped, item=item, response=response,
spider=spider, exception=output.value)
else:
- logkws = self.logformatter.error(item, ex, response, spider)
+ logkws = self.logformatter.item_error(item, ex, response, spider)
logger.log(*logformatter_adapter(logkws), extra={'spider': spider},
exc_info=failure_to_exc_info(output))
return self.signals.send_catch_log_deferred(
diff --git a/scrapy/logformatter.py b/scrapy/logformatter.py
index 5189d7cfa..79c752da4 100644
--- a/scrapy/logformatter.py
+++ b/scrapy/logformatter.py
@@ -8,7 +8,7 @@ from scrapy.utils.request import referer_str
SCRAPEDMSG = u"Scraped from %(src)s" + os.linesep + "%(item)s"
DROPPEDMSG = u"Dropped: %(exception)s" + os.linesep + "%(item)s"
CRAWLEDMSG = u"Crawled (%(status)s) %(request)s%(request_flags)s (referer: %(referer)s)%(response_flags)s"
-ERRORMSG = u"'Error processing %(item)s'"
+ITEMERRORMSG = u"'Error processing %(item)s'"
class LogFormatter(object):
@@ -93,11 +93,11 @@ class LogFormatter(object):
}
}
- def error(self, item, exception, response, spider):
+ def item_error(self, item, exception, response, spider):
"""Logs a message when an item causes an error while it is passing through the item pipeline."""
return {
'level': logging.ERROR,
- 'msg': ERRORMSG,
+ 'msg': ITEMERRORMSG,
'args': {
'item': item,
}
diff --git a/tests/test_logformatter.py b/tests/test_logformatter.py
index d0b23a8c4..f2f8c0464 100644
--- a/tests/test_logformatter.py
+++ b/tests/test_logformatter.py
@@ -63,13 +63,13 @@ class LogFormatterTestCase(unittest.TestCase):
assert all(isinstance(x, six.text_type) for x in lines)
self.assertEqual(lines, [u"Dropped: \u2018", '{}'])
- def test_error(self):
+ def test_item_error(self):
# In practice, the complete traceback is shown by passing the
# 'exc_info' argument to the logging function
item = {'key': 'value'}
exception = Exception()
response = Response("http://www.example.com")
- logkws = self.formatter.error(item, exception, response, self.spider)
+ logkws = self.formatter.item_error(item, exception, response, self.spider)
logline = logkws['msg'] % logkws['args']
self.assertEqual(logline, u"'Error processing {'key': 'value'}'")