logging: make sure logging level is set to proper value

During py.test initialization, the value 'debug' is passed instead
of logging.DEBUG.

Signed-off-by: Tomas Krizek <tkrizek@redhat.com>
Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Tomas Krizek
2017-07-18 16:07:12 +02:00
committed by Martin Babinsky
parent 0b8d460191
commit ba5f7afedc
3 changed files with 23 additions and 17 deletions

View File

@@ -23,7 +23,7 @@ import os
import sys
import logging
from ipapython.ipa_log_manager import Formatter
from ipapython.ipa_log_manager import Formatter, convert_log_level
def pytest_addoption(parser):
@@ -61,8 +61,10 @@ def pytest_configure(config):
capture._capturing.resume_capturing()
sys.stdout, sys.stderr = orig_stdout, orig_stderr
level = convert_log_level(config.getoption('logging_level'))
handler = LogHandler()
handler.setFormatter(Formatter('[%(name)s] %(message)s'))
handler.setLevel(config.getoption('logging_level'))
handler.setLevel(level)
root_logger = logging.getLogger()
root_logger.addHandler(handler)