Merge "Lower log level for notification registration"

This commit is contained in:
Jenkins 2014-09-04 08:18:02 +00:00 committed by Gerrit Code Review
commit 7d9b8dcb12
2 changed files with 9 additions and 8 deletions

View File

@ -179,14 +179,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):

View File

@ -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):