mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
logging: do not configure any handlers by default
Do not configure stderr handler by default and let the application do the configuration. Fix ipa-dnskeysync-replica and ipa-dnskeysyncd not to add stderr handler twice. Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
0562359f31
commit
464516489f
@@ -10,7 +10,7 @@ This program should be run only on replicas, not on DNSSEC masters.
|
||||
|
||||
from binascii import hexlify
|
||||
from gssapi.exceptions import GSSError
|
||||
import logging
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -123,14 +123,10 @@ def ldap2replica_zone_keys_sync(log, ldapkeydb, localhsm):
|
||||
|
||||
|
||||
# IPA framework initialization
|
||||
ipalib.api.bootstrap(
|
||||
context='dns', confdir=paths.ETC_IPA,
|
||||
in_server=True, log=None, # no logging to file
|
||||
)
|
||||
standard_logging_setup(verbose=True, debug=True)
|
||||
ipalib.api.bootstrap(context='dns', confdir=paths.ETC_IPA, in_server=True)
|
||||
ipalib.api.finalize()
|
||||
standard_logging_setup(verbose=True, debug = True) # debug=ipalib.api.env.debug)
|
||||
log = root_logger
|
||||
log.setLevel(level=logging.DEBUG)
|
||||
|
||||
# Kerberos initialization
|
||||
PRINCIPAL = str('%s/%s' % (DAEMONNAME, ipalib.api.env.host))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
|
||||
#
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import ldap
|
||||
import ldapurl
|
||||
@@ -19,13 +20,12 @@ from ipaplatform.paths import paths
|
||||
from ipaserver.dnssec.keysyncer import KeySyncer
|
||||
|
||||
# IPA framework initialization
|
||||
api.bootstrap(
|
||||
context='dns', confdir=paths.ETC_IPA,
|
||||
in_server=True, log=None, # no logging to file
|
||||
)
|
||||
standard_logging_setup(verbose=True)
|
||||
api.bootstrap(context='dns', confdir=paths.ETC_IPA, in_server=True)
|
||||
api.finalize()
|
||||
standard_logging_setup(verbose=True, debug=api.env.debug)
|
||||
log = root_logger
|
||||
if api.env.debug:
|
||||
log.setLevel(logging.DEBUG)
|
||||
#log.addHandler(systemd.journal.JournalHandler())
|
||||
|
||||
# Global state
|
||||
|
||||
@@ -457,8 +457,6 @@ class API(ReadOnly):
|
||||
else:
|
||||
level = 'warning'
|
||||
|
||||
if 'console' in log_mgr.handlers:
|
||||
log_mgr.remove_handler('console')
|
||||
log_mgr.create_log_handlers([dict(name='console',
|
||||
stream=sys.stderr,
|
||||
level=level,
|
||||
|
||||
@@ -230,6 +230,9 @@ class AdminTool(object):
|
||||
Logging to file is only set up after option validation and prompting;
|
||||
before that, all output will go to the console only.
|
||||
"""
|
||||
if 'console' in ipa_log_manager.log_mgr.handlers:
|
||||
ipa_log_manager.log_mgr.remove_handler('console')
|
||||
|
||||
self._setup_logging(log_file_mode=log_file_mode)
|
||||
|
||||
def _setup_logging(self, log_file_mode='w', no_file=False):
|
||||
|
||||
@@ -188,8 +188,6 @@ def standard_logging_setup(filename=None, verbose=False, debug=False,
|
||||
format=LOGGING_FORMAT_STANDARD_FILE)
|
||||
handlers.append(file_handler)
|
||||
|
||||
if 'console' in log_mgr.handlers:
|
||||
log_mgr.remove_handler('console')
|
||||
level = 'error'
|
||||
if verbose:
|
||||
level = 'info'
|
||||
@@ -214,14 +212,9 @@ def standard_logging_setup(filename=None, verbose=False, debug=False,
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Single shared instance of log manager
|
||||
#
|
||||
# By default always starts with stderr console handler at error level
|
||||
# so messages generated before logging is fully configured have some
|
||||
# place to got and won't get lost.
|
||||
|
||||
log_mgr = IPALogManager()
|
||||
log_mgr.configure(dict(default_level='error',
|
||||
handlers=[dict(name='console',
|
||||
stream=sys.stderr)]),
|
||||
handlers=[]),
|
||||
configure_state='default')
|
||||
root_logger = log_mgr.root_logger
|
||||
|
||||
Reference in New Issue
Block a user