mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-11-02 20:30:26 -06:00
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:
1 parent
464516489f
commit
f62a0fdb90
9 files changed
+152
-1743
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user