Skip to content

Commit

Permalink
Fix logging via toml (#2593)
Browse files Browse the repository at this point in the history
* test to reproduce bug
  • Loading branch information
orsinium authored and dlstadther committed Dec 12, 2018
1 parent 5193f84 commit 97e3be7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion luigi/setup_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion test/setup_logging_test.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit 97e3be7

Please sign in to comment.