Add default user_identity to logging record

Just like instance and color formatting parameters we can't assume that
the user_identity will always be in the logging record. This patch adds
a default value for it if missing to avoid exceptions.

Change-Id: Id02902adb2579d44f1f4f066757ef3855b5ece87
Closes-Bug: #1290503
This commit is contained in:
Luis A. Garcia 2014-03-10 22:03:08 -06:00
parent 6685f34780
commit 346884d48c
1 changed files with 1 additions and 1 deletions

View File

@ -650,7 +650,7 @@ class ContextFormatter(logging.Formatter):
# NOTE(sdague): default the fancier formatting params
# to an empty string so we don't throw an exception if
# they get used
for key in ('instance', 'color'):
for key in ('instance', 'color', 'user_identity'):
if key not in record.__dict__:
record.__dict__[key] = ''