logging: do not use ipa_log_manager to create module-level loggers

Replace all `ipa_log_manager.log_mgr.get_logger` calls to create
module-level loggers with `logging.getLogger` calls and deprecate
`ipa_log_manager.log_mgr.get_logger`.

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Jan Cholasta
2017-05-25 10:42:54 +00:00
committed by Martin Basti
parent 7a482b7c72
commit 07229c8ff6
14 changed files with 103 additions and 98 deletions

View File

@@ -6,6 +6,7 @@ import base64
import collections
import errno
import json
import logging
import os
import os.path
import pipes
@@ -31,7 +32,6 @@ import six
from ipalib import api
from ipalib import errors
from ipalib.text import _
from ipapython.ipa_log_manager import log_mgr
if six.PY3:
unicode = str
@@ -41,7 +41,7 @@ Routines for constructing certificate signing requests using IPA data and
stored templates.
""")
logger = log_mgr.get_logger(__name__)
logger = logging.getLogger(__name__)
class IndexableUndefined(jinja2.Undefined):
@@ -164,7 +164,7 @@ class Formatter(object):
'Template error when formatting certificate data'))
logger.debug(
'Formatting with template: %s' % combined_template_source)
'Formatting with template: %s', combined_template_source)
combined_template = self.jinja2.from_string(combined_template_source)
return combined_template
@@ -190,7 +190,7 @@ class Formatter(object):
def _prepare_syntax_rule(
self, syntax_rule, data_rules, description, data_sources):
logger.debug('Syntax rule template: %s' % syntax_rule.template)
logger.debug('Syntax rule template: %s', syntax_rule.template)
template = self.jinja2.from_string(
syntax_rule.template, globals=self.passthrough_globals)
is_required = syntax_rule.options.get('required', False)

View File

@@ -23,6 +23,7 @@ import base64
import errno
import io
import json
import logging
import os
import tempfile
@@ -46,9 +47,8 @@ from ipalib import Bytes, Flag, Str
from ipalib.plugable import Registry
from ipalib import _
from ipapython.dnsutil import DNSName
from ipapython.ipa_log_manager import log_mgr
logger = log_mgr.get_logger(__name__)
logger = logging.getLogger(__name__)
def validated_read(argname, filename, mode='r', encoding=None):

View File

@@ -6,6 +6,7 @@ import collections
import errno
import json
import locale
import logging
import os
import time
@@ -14,9 +15,8 @@ from . import schema
from ipaclient.plugins.rpcclient import rpcclient
from ipalib.constants import USER_CACHE_PATH
from ipapython.dnsutil import DNSName
from ipapython.ipa_log_manager import log_mgr
logger = log_mgr.get_logger(__name__)
logger = logging.getLogger(__name__)
class ServerInfo(collections.MutableMapping):
@@ -50,7 +50,7 @@ class ServerInfo(collections.MutableMapping):
pass
else:
# warn that the file is unreadable, probably corrupted
logger.warning('Failed to read server info: {}'.format(e))
logger.warning('Failed to read server info: %s', e)
def _write(self):
try:
@@ -62,7 +62,7 @@ class ServerInfo(collections.MutableMapping):
with open(self._path, 'w') as sc:
json.dump(self._dict, sc)
except EnvironmentError as e:
logger.warning('Failed to write server info: {}'.format(e))
logger.warning('Failed to write server info: %s', e)
def __getitem__(self, key):
return self._dict[key]

View File

@@ -5,6 +5,7 @@
import collections
import errno
import json
import logging
import os
import sys
import tempfile
@@ -23,7 +24,8 @@ from ipalib.parameters import DefaultFrom, Flag, Password, Str
from ipapython.ipautil import fsdecode
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
from ipapython.ipa_log_manager import log_mgr
logger = logging.getLogger(__name__)
FORMAT = '1'
@@ -57,8 +59,6 @@ _PARAMS = {
'str': parameters.Str,
}
logger = log_mgr.get_logger(__name__)
class _SchemaCommand(ClientCommand):
pass
@@ -377,7 +377,7 @@ class Schema(object):
# Failed to read the schema from cache. There may be a lot of
# causes and not much we can do about it. Just ensure we will
# ignore the cache and fetch the schema from server.
logger.warning("Failed to read schema: {}".format(e))
logger.warning("Failed to read schema: %s", e)
fingerprint = None
read_failed = True
@@ -387,7 +387,7 @@ class Schema(object):
try:
self._write_schema(fingerprint)
except Exception as e:
logger.warning("Failed to write schema: {}".format(e))
logger.warning("Failed to write schema: %s", e)
self.fingerprint = fingerprint
self.ttl = ttl