Merge "Make notify driver messaging play well with publish_errors"
This commit is contained in:
commit
711f4187d4
oslo_messaging
tests/notify
@ -35,7 +35,8 @@ class LoggingErrorNotificationHandler(logging.Handler):
|
||||
# handler sends a notification, and the log_notifier sees the
|
||||
# notification and logs it.
|
||||
return
|
||||
self._notifier.error(None, 'error_notification',
|
||||
self._notifier.error({},
|
||||
'error_notification',
|
||||
dict(error=record.msg))
|
||||
|
||||
|
||||
|
@ -64,19 +64,21 @@ class LoggingNotificationHandler(logging.Handler):
|
||||
if not method:
|
||||
return
|
||||
|
||||
method(None,
|
||||
'logrecord',
|
||||
{
|
||||
'name': record.name,
|
||||
'levelno': record.levelno,
|
||||
'levelname': record.levelname,
|
||||
'exc_info': record.exc_info,
|
||||
'pathname': record.pathname,
|
||||
'lineno': record.lineno,
|
||||
'msg': record.getMessage(),
|
||||
'funcName': record.funcName,
|
||||
'thread': record.thread,
|
||||
'processName': record.processName,
|
||||
'process': record.process,
|
||||
'extra': getattr(record, 'extra', None),
|
||||
})
|
||||
method(
|
||||
{},
|
||||
'logrecord',
|
||||
{
|
||||
'name': record.name,
|
||||
'levelno': record.levelno,
|
||||
'levelname': record.levelname,
|
||||
'exc_info': record.exc_info,
|
||||
'pathname': record.pathname,
|
||||
'lineno': record.lineno,
|
||||
'msg': record.getMessage(),
|
||||
'funcName': record.funcName,
|
||||
'thread': record.thread,
|
||||
'processName': record.processName,
|
||||
'process': record.process,
|
||||
'extra': getattr(record, 'extra', None),
|
||||
}
|
||||
)
|
||||
|
@ -54,5 +54,6 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
|
||||
self.publisherrorshandler.emit(logrecord)
|
||||
self.assertEqual('error.publisher',
|
||||
self.publisherrorshandler._notifier.publisher_id)
|
||||
mock_notify.assert_called_with(None, 'error_notification',
|
||||
mock_notify.assert_called_with({},
|
||||
'error_notification',
|
||||
{'error': 'Message'}, 'ERROR')
|
||||
|
@ -76,6 +76,9 @@ class TestLogNotifier(test_utils.BaseTestCase):
|
||||
|
||||
self.logger.emit(record)
|
||||
|
||||
context = oslo_messaging.notify._impl_test.NOTIFICATIONS[0][0]
|
||||
self.assertEqual({}, context)
|
||||
|
||||
n = oslo_messaging.notify._impl_test.NOTIFICATIONS[0][1]
|
||||
self.assertEqual(getattr(self, 'queue', self.priority.upper()),
|
||||
n['priority'])
|
||||
|
@ -54,5 +54,5 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
|
||||
self.publisherrorshandler.emit(logrecord)
|
||||
self.assertEqual('error.publisher',
|
||||
self.publisherrorshandler._notifier.publisher_id)
|
||||
mock_notify.assert_called_with(None, 'error_notification',
|
||||
mock_notify.assert_called_with({}, 'error_notification',
|
||||
{'error': 'Message'}, 'ERROR')
|
||||
|
@ -77,6 +77,9 @@ class TestLogNotifier(test_utils.BaseTestCase):
|
||||
|
||||
self.logger.emit(record)
|
||||
|
||||
context = oslo_messaging.notify._impl_test.NOTIFICATIONS[0][0]
|
||||
self.assertEqual({}, context)
|
||||
|
||||
n = oslo_messaging.notify._impl_test.NOTIFICATIONS[0][1]
|
||||
self.assertEqual(getattr(self, 'queue', self.priority.upper()),
|
||||
n['priority'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user