Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

log level specified on command line is not used #139

Closed
wants to merge 2 commits into from

3 participants

@hlongmore

An alternative to removing the illusion of supporting random integer log levels (see #138) is to actually support it by using the self.settings.overrides value that get set via a command such as

scrapy crawl --loglevel=1 --logfile=debug.log my_spider

hlongmore added some commits
@hlongmore hlongmore An alternative to removing the illusion of supporting random integer …
…log levels (see my previous pull request) is to actually support it by using the self.settings.overrides value that get set via a command such as

 >scrapy crawl --loglevel=1 --logfile=debug.log my_spider
45e1530
@hlongmore hlongmore Convert loglevel option to int if possible. ca9de94
@pablohoffman

Sorry, this works for me. What Scrapy version are you using to test?. Can you elaborate on how to reproduce a case where the log level passed by command line is not respected?

scrapy.log.start_log uses LOG_LEVEL setting internally, which the command class overrides.

@hlongmore
@pablohoffman

I still don't understand. Where does the "illusion of supporting integer log levels" come from?.

Why would you want to run scrapy --loglevel=1 instead of passing the standard level names?

@hlongmore
@dangra
Owner

although the functionality looks OK, I don't see an use case for this pull request, closing.

@dangra dangra closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 26, 2012
  1. @hlongmore

    An alternative to removing the illusion of supporting random integer …

    hlongmore authored
    …log levels (see my previous pull request) is to actually support it by using the self.settings.overrides value that get set via a command such as
    
     >scrapy crawl --loglevel=1 --logfile=debug.log my_spider
  2. @hlongmore
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 scrapy/command.py
View
9 scrapy/command.py
@@ -28,7 +28,8 @@ def set_crawler(self, crawler):
@property
def crawler(self):
if not log.started:
- log.start()
+ loglevel = self.settings.overrides.get('LOG_LEVEL', None)
+ log.start(loglevel=loglevel)
self._crawler.configure()
return self._crawler
@@ -92,7 +93,11 @@ def process_options(self, args, opts):
if opts.loglevel:
self.settings.overrides['LOG_ENABLED'] = True
- self.settings.overrides['LOG_LEVEL'] = opts.loglevel
+ try:
+ level = int(opts.loglevel)
+ except:
+ level = opts.loglevel
+ self.settings.overrides['LOG_LEVEL'] = level
if opts.nolog:
self.settings.overrides['LOG_ENABLED'] = False
Something went wrong with that request. Please try again.