mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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:
parent
f62a0fdb90
commit
9d19654cbd
@ -25,8 +25,7 @@ api.bootstrap(context='dns', confdir=paths.ETC_IPA, in_server=True)
|
||||
api.finalize()
|
||||
log = root_logger
|
||||
if api.env.debug:
|
||||
log.setLevel(logging.DEBUG)
|
||||
#log.addHandler(systemd.journal.JournalHandler())
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Global state
|
||||
watcher_running = True
|
||||
|
@ -35,6 +35,7 @@ import ipalib
|
||||
from ipalib.constants import SOFTHSM_DNSSEC_TOKEN_LABEL
|
||||
from ipalib.install.kinit import kinit_keytab
|
||||
from ipapython.dn import DN
|
||||
from ipapython.ipa_log_manager import root_logger
|
||||
from ipapython import ipaldap
|
||||
from ipaplatform.paths import paths
|
||||
from ipaserver.dnssec.abshsm import sync_pkcs11_metadata, wrappingmech_name2id
|
||||
@ -601,10 +602,10 @@ def cleanup_ldap_zone(log, ldap, dns_dn, zone_name):
|
||||
log.debug('deleting key metadata "%s"', ldap_key.dn)
|
||||
ldap.delete_entry(ldap_key)
|
||||
|
||||
log = logging.getLogger('root')
|
||||
log = root_logger
|
||||
# this service is usually socket-activated
|
||||
log.addHandler(systemd.journal.JournalHandler())
|
||||
log.setLevel(level=logging.DEBUG)
|
||||
root_logger.addHandler(systemd.journal.JournalHandler())
|
||||
root_logger.setLevel(level=logging.DEBUG)
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
print(__doc__)
|
||||
@ -612,13 +613,10 @@ if len(sys.argv) > 2:
|
||||
# program was likely invoked from console, log to it
|
||||
elif len(sys.argv) == 2:
|
||||
console = logging.StreamHandler()
|
||||
log.addHandler(console)
|
||||
root_logger.addHandler(console)
|
||||
|
||||
# IPA framework initialization
|
||||
ipalib.api.bootstrap(
|
||||
context='dns', confdir=paths.ETC_IPA,
|
||||
in_server=True, log=None, # no logging to file
|
||||
)
|
||||
ipalib.api.bootstrap(context='dns', confdir=paths.ETC_IPA, in_server=True)
|
||||
ipalib.api.finalize()
|
||||
|
||||
# Kerberos initialization
|
||||
|
@ -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()
|
||||
|
@ -507,7 +507,7 @@ class IpaAdvise(admintool.AdminTool):
|
||||
advise_api.finalize()
|
||||
if not self.options.verbose:
|
||||
# Do not print connection information by default
|
||||
logger_name = r'ipa\.ipalib\.plugins\.rpcclient'
|
||||
logger_name = r'ipalib\.plugins\.rpcclient'
|
||||
root_logger.addFilter(Filter(logger_name, logging.WARNING))
|
||||
|
||||
# With no argument, print the list out and exit
|
||||
|
Loading…
Reference in New Issue
Block a user