mirror of https://github.com/scrapy/scrapy.git
Merge 95881ee62b into c9446931a8
This commit is contained in:
commit
b63acdcfd7
|
|
@ -130,7 +130,14 @@ def configure_logging(
|
|||
if settings.getbool("LOG_STDOUT"):
|
||||
sys.stdout = StreamLogger(logging.getLogger("stdout"))
|
||||
|
||||
if install_root_handler:
|
||||
logging_from_settings = settings.getdict('LOGGING')
|
||||
|
||||
if logging_from_settings:
|
||||
LOGGING = DEFAULT_LOGGING.copy()
|
||||
LOGGING.update(logging_from_settings)
|
||||
dictConfig(LOGGING)
|
||||
|
||||
elif install_root_handler:
|
||||
install_scrapy_root_handler(settings)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
from scrapy.utils import log
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
|
||||
def test_settings_None(self):
|
||||
log.configure_logging()
|
||||
self.assertEqual(logging.getLogger().getEffectiveLevel(), 0)
|
||||
|
||||
def test_settings_LOGGING(self):
|
||||
settings = {'LOGGING': {'loggers': {'logger3': {'level': 'CRITICAL'}}}}
|
||||
log.configure_logging(settings=settings)
|
||||
self.assertEqual(logging.getLogger().getEffectiveLevel(), 30)
|
||||
self.assertEqual(logging.getLogger('logger3').getEffectiveLevel(), 50)
|
||||
Loading…
Reference in New Issue