logging: port to standard Python logging

Use the standard `logging` module to configure logging instead of the
in-house `ipapython.log_manager` module and remove `ipapython.log_manager`.

Disable the logging-not-lazy and logging-format-interpolation pylint
checks.

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Jan Cholasta authored and Martin Basti committed 2017-07-14 15:55:59 +02:00
1 parent 464516489f
commit f62a0fdb90
9 files changed
+152 -1743

No files matched your search

+6 -8
View File
@@ -25,20 +25,18 @@ If the plugin is active, sets up IPA logging to also log to Beaker.
import logging
from ipapython.ipa_log_manager import log_mgr
from ipapython.ipa_log_manager import Formatter, root_logger
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('BeakerLibPlugin')
if plugin:
root_logger.setLevel(logging.DEBUG)
handler = BeakerLibLogHandler(plugin.run_beakerlib_command)
log_mgr.configure(
{
'default_level': 'DEBUG',
'handlers': [{'log_handler': handler,
'format': '[%(name)s] %(message)s',
'level': 'info'}]},
configure_state='beakerlib_plugin')
handler.setLevel(logging.INFO)
handler.setFormatter(Formatter('[%(name)s] %(message)s'))
root_logger.addHandler(handler)
class BeakerLibLogHandler(logging.Handler):
+5 -11
View File
@@ -23,7 +23,7 @@ import os
import sys
import logging
from ipapython.ipa_log_manager import log_mgr
from ipapython.ipa_log_manager import Formatter, root_logger
def pytest_addoption(parser):
@@ -61,13 +61,7 @@ def pytest_configure(config):
capture._capturing.resume_capturing()
sys.stdout, sys.stderr = orig_stdout, orig_stderr
log_mgr.configure(
{
'default_level': config.getoption('logging_level'),
'handlers': [{'log_handler': LogHandler(),
'format': '[%(name)s] %(message)s',
'level': 'debug'},
{'level': 'debug',
'name': 'real_stderr',
'stream': sys.stderr}]},
configure_state='tests')
handler = LogHandler()
handler.setFormatter(Formatter('[%(name)s] %(message)s'))
handler.setLevel(config.getoption('logging_level'))
root_logger.addHandler(handler)