diff --git a/luigi/setup_logging.py b/luigi/setup_logging.py index f28a697cb5..8a1aeecb96 100644 --- a/luigi/setup_logging.py +++ b/luigi/setup_logging.py @@ -22,7 +22,7 @@ import logging import logging.config import os.path -from luigi.configuration import get_config +from luigi.configuration import get_config, LuigiConfigParser # In python3 ConfigParser was renamed # https://stackoverflow.com/a/41202010 @@ -38,6 +38,8 @@ class BaseLogging(object): @classmethod def _section(cls, opts): """Get logging settings from config file section "logging".""" + if isinstance(cls.config, LuigiConfigParser): + return False try: logging_config = cls.config['logging'] except (TypeError, KeyError, NoSectionError): diff --git a/test/setup_logging_test.py b/test/setup_logging_test.py index 08cc7c0753..3bc17462f0 100644 --- a/test/setup_logging_test.py +++ b/test/setup_logging_test.py @@ -1,5 +1,5 @@ from luigi.setup_logging import DaemonLogging, InterfaceLogging -from luigi.configuration import LuigiTomlParser, get_config +from luigi.configuration import LuigiTomlParser, LuigiConfigParser, get_config from helpers import unittest @@ -42,6 +42,11 @@ def test_section(self): result = self.cls._section(None) self.assertFalse(result) + def test_section_cfg(self): + self.cls.config = LuigiConfigParser.instance() + result = self.cls._section(None) + self.assertFalse(result) + def test_cfg(self): self.cls.config = LuigiTomlParser() self.cls.config.data = {}