logging: use the actual root logger as the root logger

Use the actual root logger (`logging.getLogger()`) rather than the `ipa`
logger (or the `root` logger in case of ipa-ods-exporter) as the root
logger.

Always configure logging on the root logger.

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 f62a0fdb90
commit 9d19654cbd
4 files changed
+12 -23

No files matched your search

+4 -12
View File
@@ -26,12 +26,9 @@ import six
# Module exports
__all__ = ['log_mgr', 'root_logger', 'standard_logging_setup',
'IPA_ROOT_LOGGER_NAME', 'ISO8601_UTC_DATETIME_FMT',
'ISO8601_UTC_DATETIME_FMT',
'LOGGING_FORMAT_STDERR', 'LOGGING_FORMAT_STDOUT', 'LOGGING_FORMAT_FILE']
# Our root logger, all loggers will be descendents of this.
IPA_ROOT_LOGGER_NAME = 'ipa'
# Format string for time.strftime() to produce a ISO 8601 date time
# formatted string in the UTC time zone.
ISO8601_UTC_DATETIME_FMT = '%Y-%m-%dT%H:%M:%SZ'
@@ -61,14 +58,9 @@ LOGGING_FORMAT_STANDARD_FILE = '%(asctime)s %(levelname)s %(message)s'
def get_logger(who, bind_logger_names=False):
if isinstance(who, six.string_types):
obj_name = who
logger_name = who
else:
obj_name = '%s.%s' % (who.__module__, who.__class__.__name__)
if obj_name == IPA_ROOT_LOGGER_NAME:
logger_name = obj_name
else:
logger_name = IPA_ROOT_LOGGER_NAME + '.' + obj_name
logger_name = '%s.%s' % (who.__module__, who.__class__.__name__)
logger = logging.getLogger(logger_name)
@@ -142,4 +134,4 @@ def standard_logging_setup(filename=None, verbose=False, debug=False,
# Single shared instance of log manager
log_mgr = sys.modules[__name__]
root_logger = logging.getLogger(IPA_ROOT_LOGGER_NAME)
root_logger = logging.getLogger()