Remove deprecated use-syslog-rfc-format option
This option is marked as deprecated and to be removed in Mitaka. Cleanup conditional uses of using configuration value. Change-Id: I9b77899fe437d359df2a15961866b194b564ca48 Depends-On: I3649049a571490c5ec44a14a0c8640a4b747ad64
This commit is contained in:
parent
49df1e2776
commit
ef9f69f35e
@ -88,16 +88,6 @@ logging_cli_opts = [
|
||||
'Existing syslog format is DEPRECATED '
|
||||
'and will be changed later to honor RFC5424. '
|
||||
+ _IGNORE_MESSAGE),
|
||||
cfg.BoolOpt('use-syslog-rfc-format',
|
||||
default=True,
|
||||
deprecated_for_removal=True,
|
||||
help='Enables or disables syslog rfc5424 format '
|
||||
'for logging. If enabled, prefixes the MSG part of the '
|
||||
'syslog message with APP-NAME (RFC5424). '
|
||||
+ _IGNORE_MESSAGE,
|
||||
deprecated_reason='The format without the APP-NAME is '
|
||||
'deprecated in Kilo, and will be removed in '
|
||||
'Mitaka, along with this option. '),
|
||||
cfg.StrOpt('syslog-log-facility',
|
||||
default='LOG_USER',
|
||||
help='Syslog facility to receive log lines. '
|
||||
|
@ -20,8 +20,6 @@ try:
|
||||
except ImportError:
|
||||
syslog = None
|
||||
|
||||
from debtcollector import removals
|
||||
|
||||
|
||||
NullHandler = logging.NullHandler
|
||||
|
||||
@ -30,27 +28,6 @@ def _get_binary_name():
|
||||
return os.path.basename(inspect.stack()[-1][1])
|
||||
|
||||
|
||||
class RFCSysLogHandler(logging.handlers.SysLogHandler):
|
||||
"""SysLogHandler following the RFC
|
||||
|
||||
.. deprecated:: 1.2.0
|
||||
Use :class:`OSSysLogHandler` instead
|
||||
"""
|
||||
|
||||
@removals.remove(
|
||||
message='use oslo_log.handlers.OSSysLogHandler()',
|
||||
version='1.2.0',
|
||||
removal_version='?',
|
||||
)
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.binary_name = _get_binary_name()
|
||||
super(RFCSysLogHandler, self).__init__(*args, **kwargs)
|
||||
|
||||
def format(self, record):
|
||||
msg = super(RFCSysLogHandler, self).format(record)
|
||||
msg = self.binary_name + ' ' + msg
|
||||
return msg
|
||||
|
||||
_AUDIT = logging.INFO + 1
|
||||
_TRACE = 5
|
||||
|
||||
@ -67,15 +44,11 @@ if syslog is not None:
|
||||
"WARN": syslog.LOG_WARNING,
|
||||
}
|
||||
|
||||
def __init__(self, facility=syslog.LOG_USER,
|
||||
use_syslog_rfc_format=True):
|
||||
def __init__(self, facility=syslog.LOG_USER):
|
||||
# Do not use super() unless type(logging.Handler) is 'type'
|
||||
# (i.e. >= Python 2.7).
|
||||
logging.Handler.__init__(self)
|
||||
if use_syslog_rfc_format:
|
||||
binary_name = _get_binary_name()
|
||||
else:
|
||||
binary_name = ""
|
||||
binary_name = _get_binary_name()
|
||||
syslog.openlog(binary_name, 0, facility)
|
||||
|
||||
def emit(self, record):
|
||||
|
@ -340,11 +340,7 @@ def _setup_logging_from_conf(conf, project, version):
|
||||
if syslog is None:
|
||||
raise RuntimeError("syslog is not available on this platform")
|
||||
facility = _find_facility(conf.syslog_log_facility)
|
||||
# TODO(bogdando) use the format provided by RFCSysLogHandler after
|
||||
# existing syslog format deprecation in J
|
||||
syslog_handler = handlers.OSSysLogHandler(
|
||||
facility=facility,
|
||||
use_syslog_rfc_format=conf.use_syslog_rfc_format)
|
||||
syslog_handler = handlers.OSSysLogHandler(facility=facility)
|
||||
log_root.addHandler(syslog_handler)
|
||||
|
||||
datefmt = conf.log_date_format
|
||||
|
@ -200,27 +200,15 @@ class LogHandlerTestCase(BaseTestCase):
|
||||
|
||||
|
||||
class SysLogHandlersTestCase(BaseTestCase):
|
||||
"""Test for standard and RFC compliant Syslog handlers."""
|
||||
"""Test the standard Syslog handler."""
|
||||
def setUp(self):
|
||||
super(SysLogHandlersTestCase, self).setUp()
|
||||
self.facility = logging.handlers.SysLogHandler.LOG_USER
|
||||
self.rfclogger = handlers.RFCSysLogHandler(facility=self.facility)
|
||||
self.rfclogger.binary_name = 'Foo_application'
|
||||
self.logger = logging.handlers.SysLogHandler(facility=self.facility)
|
||||
self.logger.binary_name = 'Foo_application'
|
||||
|
||||
def test_rfc_format(self):
|
||||
"""Ensure syslog msg contains APP-NAME for RFC wrapped handler."""
|
||||
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||
'Message', None, None)
|
||||
expected = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||
'Foo_application Message', None, None)
|
||||
self.assertEqual(self.rfclogger.format(logrecord),
|
||||
expected.getMessage())
|
||||
|
||||
def test_standard_format(self):
|
||||
"""Ensure syslog msg isn't modified for standard handler."""
|
||||
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||
logrecord = logging.LogRecord('name', logging.WARNING, '/tmp', 1,
|
||||
'Message', None, None)
|
||||
expected = logrecord
|
||||
self.assertEqual(self.logger.format(logrecord),
|
||||
@ -229,7 +217,7 @@ class SysLogHandlersTestCase(BaseTestCase):
|
||||
|
||||
@testtools.skipUnless(syslog, "syslog is not available")
|
||||
class OSSysLogHandlerTestCase(BaseTestCase):
|
||||
def tests_handler(self):
|
||||
def test_handler(self):
|
||||
handler = handlers.OSSysLogHandler()
|
||||
syslog.syslog = mock.Mock()
|
||||
handler.emit(
|
||||
@ -238,6 +226,15 @@ class OSSysLogHandlerTestCase(BaseTestCase):
|
||||
None, None))
|
||||
self.assertTrue(syslog.syslog.called)
|
||||
|
||||
def test_syslog_binary_name(self):
|
||||
# There is no way to test the actual output written to the
|
||||
# syslog (e.g. /var/log/syslog) to confirm binary_name value
|
||||
# is actually present
|
||||
syslog.openlog = mock.Mock()
|
||||
handlers.OSSysLogHandler()
|
||||
syslog.openlog.assert_called_with(handlers._get_binary_name(),
|
||||
0, syslog.LOG_USER)
|
||||
|
||||
def test_find_facility(self):
|
||||
self.assertEqual(syslog.LOG_USER, log._find_facility("user"))
|
||||
self.assertEqual(syslog.LOG_LPR, log._find_facility("LPR"))
|
||||
@ -847,7 +844,6 @@ class LogConfigOptsTestCase(BaseTestCase):
|
||||
_options._DEFAULT_LOG_DATE_FORMAT)
|
||||
|
||||
self.assertEqual(self.CONF.use_syslog, False)
|
||||
self.assertEqual(self.CONF.use_syslog_rfc_format, True)
|
||||
|
||||
def test_log_file(self):
|
||||
log_file = '/some/path/foo-bar.log'
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
upgrade:
|
||||
- The deprecated use_syslog_rfc_format configuration option has been
|
||||
removed.
|
Loading…
x
Reference in New Issue
Block a user