From 80cd534f920f51ab42756cc8ee970b8392695d8c Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Thu, 25 Jun 2009 16:48:04 -0300 Subject: [PATCH] removed redundant botname from log lines --- docs/intro/tutorial.rst | 16 ++++++++-------- scrapy/log/__init__.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/intro/tutorial.rst b/docs/intro/tutorial.rst index c4f832509..4adb971e8 100644 --- a/docs/intro/tutorial.rst +++ b/docs/intro/tutorial.rst @@ -138,16 +138,16 @@ you'll get an output like this:: [dmoz] INFO: Enabled item pipelines: ... [-] scrapy.management.web.WebConsole starting on 60738 [-] scrapy.management.telnet.TelnetConsole starting on 51506 - [dmoz/dmoz.org] INFO: Domain opened - [dmoz/dmoz.org] DEBUG: Crawled from - [dmoz/dmoz.org] DEBUG: Crawled from - [dmoz/dmoz.org] INFO: Domain closed (finished) + [dmoz.org] INFO: Domain opened + [dmoz.org] DEBUG: Crawled from + [dmoz.org] DEBUG: Crawled from + [dmoz.org] INFO: Domain closed (finished) [scrapy.management.web.WebConsole] (Port 60738 Closed) [scrapy.management.telnet.TelnetConsole] (Port 51506 Closed) [-] Main loop terminated. -Pay attention to the lines labeled ``[dmoz/dmoz.org]``, which corresponds to -our spider identified by the domain "dmoz.org". You can see a log line for each +Pay attention to the lines containing ``[dmoz.org]``, which corresponds to +our spider (identified by the domain "dmoz.org"). You can see a log line for each URL defined in ``start_urls``. Because these URLs are the starting ones, they have no referrers, which is shown at the end of the log line, where it says ``from ``. @@ -386,8 +386,8 @@ should be like this:: Now doing a crawl on the dmoz.org domain yields ``DmozItem``'s:: - [dmoz/dmoz.org] INFO: Scraped DmozItem({'title': [u'Text Processing in Python'], 'link': [u'http://gnosis.cx/TPiP/'], 'desc': [u' - By David Mertz; Addison Wesley. Book in progress, full text, ASCII format. Asks for feedback. [author website, Gnosis Software, Inc.]\n']}) in - [dmoz/dmoz.org] INFO: Scraped DmozItem({'title': [u'XML Processing with Python'], 'link': [u'http://www.informit.com/store/product.aspx?isbn=0130211192'], 'desc': [u' - By Sean McGrath; Prentice Hall PTR, 2000, ISBN 0130211192, has CD-ROM. Methods to build XML applications fast, Python tutorial, DOM and SAX, new Pyxie open source XML processing library. [Prentice Hall PTR]\n']}) in + [dmoz.org] INFO: Scraped DmozItem({'title': [u'Text Processing in Python'], 'link': [u'http://gnosis.cx/TPiP/'], 'desc': [u' - By David Mertz; Addison Wesley. Book in progress, full text, ASCII format. Asks for feedback. [author website, Gnosis Software, Inc.]\n']}) in + [dmoz.org] INFO: Scraped DmozItem({'title': [u'XML Processing with Python'], 'link': [u'http://www.informit.com/store/product.aspx?isbn=0130211192'], 'desc': [u' - By Sean McGrath; Prentice Hall PTR, 2000, ISBN 0130211192, has CD-ROM. Methods to build XML applications fast, Python tutorial, DOM and SAX, new Pyxie open source XML processing library. [Prentice Hall PTR]\n']}) in Storing the data (using an Item Pipeline) diff --git a/scrapy/log/__init__.py b/scrapy/log/__init__.py index f9671e006..7860b538e 100644 --- a/scrapy/log/__init__.py +++ b/scrapy/log/__init__.py @@ -51,10 +51,10 @@ def start(logfile=None, loglevel=None, log_stdout=None): def msg(message, level=INFO, component=BOT_NAME, domain=None): """Log message according to the level""" - component = "%s/%s" % (component, domain) if domain else component + system = domain if domain else component if level <= log_level: msg_txt = unicode_to_str("%s: %s" % (level_names[level], message)) - log.msg(msg_txt, system=component) + log.msg(msg_txt, system=system) def exc(message, level=ERROR, component=BOT_NAME, domain=None): message = message + '\n' + format_exc() @@ -63,5 +63,5 @@ def exc(message, level=ERROR, component=BOT_NAME, domain=None): def err(*args, **kwargs): domain = kwargs.pop('domain', None) component = kwargs.pop('component', BOT_NAME) - kwargs['system'] = "%s/%s" % (component, domain) if domain else component + kwargs['system'] = domain if domain else component log.err(*args, **kwargs)