Ranger Agent - Configurable log levels (446126)

Set the logging level from the conf file to override the default level.
Default level is now made to ERROR.

Change-Id: I982839509643036cfb8038f85f63f4e6ca33d74b
This commit is contained in:
ranadheer 2018-12-27 18:45:59 +05:30
parent fe41f3f500
commit 1dfc0eb8fd
3 changed files with 17 additions and 24 deletions

View File

@ -1,7 +1,9 @@
[DEFAULT]
api_workers = 1
debug = True
verbose = True
# debug_level indicates the logging level to be set. Set to ERROR by default
# Configure the value to override the setting.
# Valid values are CRITICAL, DEBUG, ERROR, INFO, WARN
debug_level = 'DEBUG'
pecan_debug = True
region = local
repo_connection_timeout = 120

View File

@ -1,7 +1,7 @@
[DEFAULT]
api_paste_config = /etc/ranger-agent/api-paste.ini
api_workers = 1
debug = false
debug_level = 'DEBUG'
enable_rds_callback_check = false
local_repo = ranger_repo
log_dir = /var/log/ranger-agent
@ -13,7 +13,6 @@ resource_creation_timeout_max = 14400
resource_creation_timeout_min = 1200
resource_status_check_wait = 15
transport_url = rabbit://ranger-agent:password@rabbitmq.openstack.svc.cluster.local:5672/ranger-agent
verbose = true
[api]
host = 0.0.0.0

View File

@ -51,21 +51,11 @@ from ord.openstack.common import local
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
common_cli_opts = [
cfg.BoolOpt('debug',
short='d',
default=False,
help='Print debugging output (set logging level to '
'DEBUG instead of default WARNING level).'),
cfg.BoolOpt('verbose',
short='v',
default=False,
help='Print more verbose output (set logging level to '
'INFO instead of default WARNING level).'),
]
logging_cli_opts = [
cfg.StrOpt('debug_level',
default='ERROR',
choices=('CRITICAL', 'DEBUG', 'ERROR', 'INFO', 'WARN'),
help='logging debug level'),
cfg.StrOpt('log-config-append',
metavar='PATH',
deprecated_name='log-config',
@ -169,7 +159,6 @@ log_opts = [
]
CONF = cfg.CONF
CONF.register_cli_opts(common_cli_opts)
CONF.register_cli_opts(logging_cli_opts)
CONF.register_opts(generic_log_opts)
CONF.register_opts(log_opts)
@ -177,8 +166,7 @@ CONF.register_opts(log_opts)
def list_opts():
"""Entry point for oslo.config-generator."""
return [(None, copy.deepcopy(common_cli_opts)),
(None, copy.deepcopy(logging_cli_opts)),
return [(None, copy.deepcopy(logging_cli_opts)),
(None, copy.deepcopy(generic_log_opts)),
(None, copy.deepcopy(log_opts)),
]
@ -529,12 +517,16 @@ def _setup_logging_from_conf(project, version):
version=version,
datefmt=datefmt))
if CONF.debug:
if CONF.debug_level == 'CRITICAL':
log_root.setLevel(logging.CRITICAL)
elif CONF.debug_level == 'DEBUG':
log_root.setLevel(logging.DEBUG)
elif CONF.verbose:
elif CONF.debug_level == 'INFO':
log_root.setLevel(logging.INFO)
else:
elif CONF.debug_level == 'WARN':
log_root.setLevel(logging.WARNING)
else:
log_root.setLevel(logging.ERROR)
for pair in CONF.default_log_levels:
mod, _sep, level_name = pair.partition('=')