Lower log level for notification registration
Registering an internal notification isn't something that an admin would generally be interested in, and if they are they can configure debug logging for keystone.notifications. Closes-Bug: #1363704 Change-Id: Id7cd3bf2e1f373b818329978553eb53af399386c
This commit is contained in:
parent
61394c8e97
commit
7ce8d7e531
|
@ -180,14 +180,13 @@ def register_event_callback(event, resource_type, callbacks):
|
|||
_SUBSCRIBERS.setdefault(event, {}).setdefault(resource_type, set())
|
||||
_SUBSCRIBERS[event][resource_type].add(callback)
|
||||
|
||||
if LOG.logger.getEffectiveLevel() <= logging.INFO:
|
||||
if LOG.logger.getEffectiveLevel() <= logging.DEBUG:
|
||||
# Do this only if its going to appear in the logs.
|
||||
msg = _('Callback: `%(callback)s` subscribed to event '
|
||||
'`%(event)s`.')
|
||||
msg = 'Callback: `%(callback)s` subscribed to event `%(event)s`.'
|
||||
callback_info = _get_callback_info(callback)
|
||||
callback_str = '.'.join(i for i in callback_info if i is not None)
|
||||
event_str = '.'.join(['identity', resource_type, event])
|
||||
LOG.info(msg, {'callback': callback_str, 'event': event_str})
|
||||
LOG.debug(msg, {'callback': callback_str, 'event': event_str})
|
||||
|
||||
|
||||
def notify_event_callbacks(service, resource_type, operation, payload):
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
|
@ -696,7 +697,7 @@ class TestCallbackRegistration(testtools.TestCase):
|
|||
super(TestCallbackRegistration, self).setUp()
|
||||
self.mock_log = mock.Mock()
|
||||
# Force the callback logging to occur
|
||||
self.mock_log.logger.getEffectiveLevel.return_value = 1
|
||||
self.mock_log.logger.getEffectiveLevel.return_value = logging.DEBUG
|
||||
|
||||
def verify_log_message(self, data):
|
||||
"""Tests that use this are a little brittle because adding more
|
||||
|
@ -705,9 +706,10 @@ class TestCallbackRegistration(testtools.TestCase):
|
|||
TODO(dstanek): remove the need for this in a future refactoring
|
||||
|
||||
"""
|
||||
self.assertEqual(len(data), self.mock_log.info.call_count)
|
||||
for i, data in enumerate(data):
|
||||
self.mock_log.info.assert_any_call(mock.ANY, data)
|
||||
log_fn = self.mock_log.debug
|
||||
self.assertEqual(len(data), log_fn.call_count)
|
||||
for datum in data:
|
||||
log_fn.assert_any_call(mock.ANY, datum)
|
||||
|
||||
def test_a_function_callback(self):
|
||||
def callback(*args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue