Truncate the logline in logging wrapper

* This will prevent tons of text being
  thrown in to the logs by SLOs, DLOS,
  lots of querey params, etc.

Change-Id: I04504bf1773552127d7cd596f9ea072f1064efd2
This commit is contained in:
josh7810 2017-04-04 17:05:16 -05:00
parent bbaff13c5c
commit 1a8e4893b6
1 changed files with 4 additions and 0 deletions

View File

@ -57,6 +57,10 @@ def _log_transaction(log, level=cclogging.logging.DEBUG):
log level.
"""
logline = '{0} {1}'.format(args, kwargs)
# If the logline is over 200, just show the first 200 characters
# and truncate the rest.
if logline and len(logline) > 200:
logline = '{0}...<truncated>'.format(logline[:200])
try:
log.debug(logline.decode('utf-8', 'replace'))