Remove 'verbose' option (again)

The deprecation for this was merged on aug 1, 2015 in review:
https://review.openstack.org/#/c/206437/
That was a long time ago so it should be possible to remove it now.

This was already merged once but had to be reverted because some
projects were still relying on it. Let's try again, this time using
INFO default not WARNING, thanks dtantsur!

Depends-On: I713e9e5107a64ec29c220d1150c1bf5fcf6f1135
Depends-On: I102e8c7bca508b17ce2987b33148e99c79d0c147

Change-Id: I9e2bf358a0b7a2413388007b33902b91de522b22
This commit is contained in:
Alexis Lee 2016-05-10 14:38:08 +01:00 committed by ChangBo Guo(gcb)
parent 639404266f
commit 9e3afbf14c
4 changed files with 17 additions and 40 deletions

View File

@ -37,12 +37,6 @@ common_cli_opts = [
mutable=True,
help='If set to true, the logging level will be set to '
'DEBUG instead of the default INFO level.'),
cfg.BoolOpt('verbose',
short='v',
default=True,
help='If set to false, the logging level will be set to '
'WARNING instead of the default INFO level.',
deprecated_for_removal=True),
]
logging_cli_opts = [

View File

@ -232,10 +232,8 @@ def _load_log_config(log_config_append):
def _mutate_hook(conf, fresh):
"""Reconfigures oslo.log according to the mutated options."""
# verbose is deprecated, so I didn't make it mutable, so there's no need to
# test for it here.
if (None, 'debug') in fresh:
_refresh_root_level(conf.debug, conf.verbose)
_refresh_root_level(conf.debug)
if (None, 'log-config-append') in fresh:
_load_log_config.old_time = 0
@ -327,25 +325,19 @@ def _find_facility(facility):
return getattr(syslog, facility)
def _refresh_root_level(debug, verbose):
def _refresh_root_level(debug):
"""Set the level of the root logger.
If 'debug' is True, the level will be DEBUG. Otherwise we look at 'verbose'
- if that is True, the level will be INFO. If neither are set, the level
will be WARNING.
Note the 'verbose' option is deprecated.
If 'debug' is True, the level will be DEBUG. Otherwise the level will be
INFO.
:param debug
:param verbose
"""
log_root = getLogger(None).logger
if debug:
log_root.setLevel(logging.DEBUG)
elif verbose:
log_root.setLevel(logging.INFO)
else:
log_root.setLevel(logging.WARNING)
log_root.setLevel(logging.INFO)
def _setup_logging_from_conf(conf, project, version):
@ -396,7 +388,7 @@ def _setup_logging_from_conf(conf, project, version):
version=version,
datefmt=datefmt,
config=conf))
_refresh_root_level(conf.debug, conf.verbose)
_refresh_root_level(conf.debug)
for pair in conf.default_log_levels:
mod, _sep, level_name = pair.partition('=')

View File

@ -107,13 +107,6 @@ class CommonLoggerTestsMixIn(object):
self.log.info("foo", context=_fake_context())
self.assertTrue(True) # didn't raise exception
def test_will_be_verbose_if_verbose_flag_set(self):
self.config(verbose=True)
logger_name = 'test_is_verbose'
log.setup(self.CONF, logger_name)
logger = logging.getLogger(logger_name)
self.assertEqual(logging.INFO, logger.getEffectiveLevel())
def test_will_be_debug_if_debug_flag_set(self):
self.config(debug=True)
logger_name = 'test_is_debug'
@ -121,12 +114,12 @@ class CommonLoggerTestsMixIn(object):
logger = logging.getLogger(logger_name)
self.assertEqual(logging.DEBUG, logger.getEffectiveLevel())
def test_will_not_be_verbose_if_verbose_flag_not_set(self):
self.config(verbose=False)
logger_name = 'test_is_not_verbose'
def test_will_be_info_if_debug_flag_not_set(self):
self.config(debug=False)
logger_name = 'test_is_not_debug'
log.setup(self.CONF, logger_name)
logger = logging.getLogger(logger_name)
self.assertEqual(logging.WARN, logger.getEffectiveLevel())
self.assertEqual(logging.INFO, logger.getEffectiveLevel())
def test_no_logging_via_module(self):
for func in ('critical', 'error', 'exception', 'warning', 'warn',
@ -309,8 +302,7 @@ class LogLevelTestCase(BaseTestCase):
levels.append(warn_level + '=WARN')
levels.append(other_level + '=7')
levels.append(trace_level + '=TRACE')
self.config(default_log_levels=levels,
verbose=True)
self.config(default_log_levels=levels)
log.setup(self.CONF, 'testing')
self.log = log.getLogger(info_level)
self.log_no_debug = log.getLogger(warn_level)
@ -1067,14 +1059,12 @@ class MutateTestCase(BaseTestCase):
log_root = log.getLogger(None).logger
log._setup_logging_from_conf(self.CONF, 'test', 'test')
self.assertEqual(False, self.CONF.debug)
self.assertEqual(True, self.CONF.verbose)
self.assertEqual(log.INFO, log_root.getEffectiveLevel())
shutil.copy(paths[1], paths[0])
self.CONF.mutate_config_files()
self.assertEqual(True, self.CONF.debug)
self.assertEqual(True, self.CONF.verbose)
self.assertEqual(log.DEBUG, log_root.getEffectiveLevel())
@mock.patch.object(logging.config, "fileConfig")
@ -1313,14 +1303,12 @@ class LogConfigOptsTestCase(BaseTestCase):
f = six.StringIO()
self.CONF([])
self.CONF.print_help(file=f)
for option in ['debug', 'verbose', 'log-config', 'watch-log-file']:
for option in ['debug', 'log-config', 'watch-log-file']:
self.assertIn(option, f.getvalue())
def test_debug_verbose(self):
self.CONF(['--debug', '--verbose'])
def test_debug(self):
self.CONF(['--debug'])
self.assertEqual(True, self.CONF.debug)
self.assertEqual(True, self.CONF.verbose)
def test_logging_opts(self):
self.CONF([])

View File

@ -0,0 +1,3 @@
---
upgrade:
- The deprecated 'verbose' option has been removed.