Skip to content

Instantly share code, notes, and snippets.

@dangra
Created January 3, 2013 18:56
Show Gist options
  • Save dangra/4445963 to your computer and use it in GitHub Desktop.
Save dangra/4445963 to your computer and use it in GitHub Desktop.
diff --git a/scrapy/log.py b/scrapy/log.py
index be2c1fd..83be049 100644
--- a/scrapy/log.py
+++ b/scrapy/log.py
@@ -1,4 +1,4 @@
-"""
+"""
Scrapy logging facility
See documentation in docs/topics/logging.rst
@@ -7,11 +7,11 @@ import sys
import logging
import warnings
-from twisted.python import log
+from twisted.python import log, _safeFormat
import scrapy
from scrapy.utils.python import unicode_to_str
-
+
# Logging levels
DEBUG = logging.DEBUG
INFO = logging.INFO
@@ -131,6 +131,8 @@ def msg(message=None, _level=INFO, **kw):
def err(_stuff=None, _why=None, **kw):
kw['logLevel'] = kw.pop('level', ERROR)
kw.setdefault('system', 'scrapy')
+ if _why is None and 'format' in kw:
+ _why = _safeFormat(kw['format'], kw)
log.err(_stuff, _why, **kw)
def start_from_crawler(crawler):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment