Remove deprecated log-format option
Removes option marked as deprecated in Kilo and cleans up handler definition to only use ContextFormatter Change-Id: I09d7dcd0aeb91c2268365a90c491d46b979a49f1
This commit is contained in:
parent
185c10a36b
commit
b0aff1af5d
|
@ -53,19 +53,10 @@ logging_cli_opts = [
|
|||
'is appended to any existing logging configuration '
|
||||
'files. For details about logging configuration files, '
|
||||
'see the Python logging module documentation. Note that '
|
||||
'when logging configuration files are used all '
|
||||
'logging configuration is defined in the configuration '
|
||||
'file and other logging configuration options are ignored '
|
||||
'(for example, log_format).'),
|
||||
cfg.StrOpt('log-format',
|
||||
metavar='FORMAT',
|
||||
help='DEPRECATED. '
|
||||
'A logging.Formatter log message format string which may '
|
||||
'use any of the available logging.LogRecord attributes. '
|
||||
'This option is deprecated. Please use '
|
||||
'logging_context_format_string and '
|
||||
'logging_default_format_string instead. This option is '
|
||||
'ignored if log_config_append is set.'),
|
||||
'when logging configuration files are used then all '
|
||||
'logging configuration is set in the configuration file '
|
||||
'and other logging configuration options are ignored '
|
||||
'(for example, logging_context_format_string).'),
|
||||
cfg.StrOpt('log-date-format',
|
||||
default=_DEFAULT_LOG_DATE_FORMAT,
|
||||
metavar='DATE_FORMAT',
|
||||
|
|
|
@ -349,18 +349,10 @@ def _setup_logging_from_conf(conf, project, version):
|
|||
|
||||
datefmt = conf.log_date_format
|
||||
for handler in log_root.handlers:
|
||||
# NOTE(alaski): CONF.log_format overrides everything currently. This
|
||||
# should be deprecated in favor of context aware formatting.
|
||||
if conf.log_format:
|
||||
handler.setFormatter(logging.Formatter(fmt=conf.log_format,
|
||||
datefmt=datefmt))
|
||||
log_root.info('Deprecated: log_format is now deprecated and will '
|
||||
'be removed in the next release')
|
||||
else:
|
||||
handler.setFormatter(formatters.ContextFormatter(project=project,
|
||||
version=version,
|
||||
datefmt=datefmt,
|
||||
config=conf))
|
||||
handler.setFormatter(formatters.ContextFormatter(project=project,
|
||||
version=version,
|
||||
datefmt=datefmt,
|
||||
config=conf))
|
||||
|
||||
if conf.debug:
|
||||
log_root.setLevel(logging.DEBUG)
|
||||
|
|
|
@ -828,7 +828,6 @@ class LogConfigOptsTestCase(BaseTestCase):
|
|||
self.assertTrue('debug' in f.getvalue())
|
||||
self.assertTrue('verbose' in f.getvalue())
|
||||
self.assertTrue('log-config' in f.getvalue())
|
||||
self.assertTrue('log-format' in f.getvalue())
|
||||
self.assertTrue('watch-log-file' in f.getvalue())
|
||||
|
||||
def test_debug_verbose(self):
|
||||
|
@ -843,7 +842,6 @@ class LogConfigOptsTestCase(BaseTestCase):
|
|||
self.assertIsNone(self.CONF.log_config_append)
|
||||
self.assertIsNone(self.CONF.log_file)
|
||||
self.assertIsNone(self.CONF.log_dir)
|
||||
self.assertIsNone(self.CONF.log_format)
|
||||
|
||||
self.assertEqual(self.CONF.log_date_format,
|
||||
_options._DEFAULT_LOG_DATE_FORMAT)
|
||||
|
@ -899,14 +897,6 @@ class LogConfigOptsTestCase(BaseTestCase):
|
|||
self.CONF(['--logdir', logdir])
|
||||
self.assertEqual(self.CONF.log_dir, logdir)
|
||||
|
||||
def test_log_format_overrides_formatter(self):
|
||||
self.CONF(['--log-format', '[Any format]'])
|
||||
log._setup_logging_from_conf(self.CONF, 'test', 'test')
|
||||
logger = log._loggers[None].logger
|
||||
for handler in logger.handlers:
|
||||
formatter = handler.formatter
|
||||
self.assertTrue(isinstance(formatter, logging.Formatter))
|
||||
|
||||
def test_default_formatter(self):
|
||||
log._setup_logging_from_conf(self.CONF, 'test', 'test')
|
||||
logger = log._loggers[None].logger
|
||||
|
|
Loading…
Reference in New Issue