Add newlines to long log messages

This commit is contained in:
Jan Petykiewicz 2019-05-25 12:40:17 -07:00
parent dcd8324eb4
commit 49982f1207

View File

@ -508,7 +508,7 @@ def _disambiguate_pattern_names(patterns):
for pat in patterns: for pat in patterns:
if len(pat.name) > 32: if len(pat.name) > 32:
shortened_name = pat.name[:26] shortened_name = pat.name[:26]
logger.warning('Pattern name "{}" is too long ({}/32 chars),'.format(pat.name, len(pat.name)) + \ logger.warning('Pattern name "{}" is too long ({}/32 chars),\n'.format(pat.name, len(pat.name)) +
' shortening to "{}" before generating suffix'.format(shortened_name)) ' shortening to "{}" before generating suffix'.format(shortened_name))
else: else:
shortened_name = pat.name shortened_name = pat.name
@ -526,15 +526,15 @@ def _disambiguate_pattern_names(patterns):
if sanitized_name == '': if sanitized_name == '':
logger.warning('Empty pattern name saved as "{}"'.format(suffixed_name)) logger.warning('Empty pattern name saved as "{}"'.format(suffixed_name))
elif suffixed_name != sanitized_name: elif suffixed_name != sanitized_name:
logger.warning('Pattern name "{}" ({}) appears multiple times; renaming to "{}"'.format( logger.warning('Pattern name "{}" ({}) appears multiple times;\n renaming to "{}"'.format(
pat.name, sanitized_name, suffixed_name)) pat.name, sanitized_name, suffixed_name))
encoded_name = suffixed_name.encode('ASCII') encoded_name = suffixed_name.encode('ASCII')
if len(encoded_name) == 0: if len(encoded_name) == 0:
# Should never happen since zero-length names are replaced # Should never happen since zero-length names are replaced
raise PatternError('Zero-length name after sanitize+encode, originally "{}"'.format(pat.name)) raise PatternError('Zero-length name after sanitize+encode,\n originally "{}"'.format(pat.name))
if len(encoded_name) > 32: if len(encoded_name) > 32:
raise PatternError('Pattern name "{}" length > 32 after encode, originally "{}"'.format(encoded_name, pat.name)) raise PatternError('Pattern name "{}" length > 32 after encode,\n originally "{}"'.format(encoded_name, pat.name))
pat.name = encoded_name pat.name = encoded_name
used_names.append(suffixed_name) used_names.append(suffixed_name)