Revert "Add common oslo.log format parameters"

This reverts commit 01aaeae060.
This causes test failures with oslo.log change
Ica445ad5dfe9bd27dfcf1b1bcb6401a0bc9496a5 when passing these attributes
to a log message and a context object. The result of setting these in
context causes log.record values to be overridden with blank values.
Catering for this condition causes subsequent mismatches for test
conditions mixing context and optional passing additional attributes
to log.

Change-Id: I5450e105dc914f822a2b4c03b759a682d8b4a3e7
This commit is contained in:
Ronald Bradford 2016-02-23 18:53:54 +00:00
parent 01aaeae060
commit 217a4edc2e
2 changed files with 1 additions and 30 deletions

View File

@ -102,15 +102,7 @@ class RequestContext(object):
def get_logging_values(self):
"""Return a dictionary of logging specific context attributes."""
# Define these attributes so that oslo.log does not throw an exception
# if used in any formatting strings
values = {'instance': '',
'resource': '',
'user_name': '',
'project_name': '',
'color': ''}
values.update(self.to_dict())
values = self.to_dict()
return values
@classmethod

View File

@ -261,11 +261,6 @@ class ContextTest(test_base.BaseTestCase):
self.assertIn('request_id', d)
self.assertIn('resource_uuid', d)
self.assertIn('user_identity', d)
self.assertIn('instance', d)
self.assertIn('resource', d)
self.assertIn('user_name', d)
self.assertIn('project_name', d)
self.assertIn('color', d)
self.assertEqual(auth_token, d['auth_token'])
self.assertEqual(tenant, d['tenant'])
@ -280,22 +275,6 @@ class ContextTest(test_base.BaseTestCase):
user_identity = "%s %s %s %s %s" % (user, tenant, domain,
user_domain, project_domain)
self.assertEqual(user_identity, d['user_identity'])
self.assertEqual("", d['instance'])
self.assertEqual("", d['resource'])
self.assertEqual("", d['user_name'])
self.assertEqual("", d['project_name'])
self.assertEqual("", d['color'])
def test_get_logging_values_extra_attributes(self):
ctx = context.RequestContext()
d = ctx.get_logging_values()
self.assertEqual("", d['color'])
color = "red"
setattr(ctx, "color", color)
d = ctx.get_logging_values()
# Regardless of setting attribute, this is not affected as this
# is not included in to_dict().
self.assertEqual("", d['color'])
def test_dict_empty_user_identity(self):
ctx = context.RequestContext()