This commit is contained in:
Taito Horiuchi 2026-07-10 08:09:22 +08:00 committed by GitHub
commit b63acdcfd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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)