logger: don't shadow args; restore original record.args type

This commit is contained in:
panni 2018-11-28 13:43:09 +01:00
parent 4c7c7a692b
commit 10195df70e
1 changed files with 8 additions and 6 deletions

View File

@ -115,13 +115,14 @@ class BlacklistFilter(logging.Filter):
record.msg = record.msg.replace(apikey, 8 * '*' + apikey[-2:])
if isinstance(record.args, (types.ListType, types.TupleType)):
args = []
final_args = []
for arg in record.args:
if not isinstance(arg, basestring):
final_args.append(arg)
continue
args.append(mask_apikeys(arg))
record.args = tuple(args)
final_args.append(mask_apikeys(arg))
record.args = record.args = type(record.args)(final_args)
elif isinstance(record.args, dict):
for key, arg in record.args.items():
if not isinstance(arg, basestring):
@ -155,14 +156,15 @@ class PublicIPFilter(logging.Filter):
record.msg = record.msg.replace(ip, ip.partition('.')[0] + '.***.***.***')
if isinstance(record.args, (types.ListType, types.TupleType)):
args = []
final_args = []
for arg in record.args:
if not isinstance(arg, basestring):
final_args.append(arg)
continue
args.append(mask_ipv4(arg))
final_args.append(mask_ipv4(arg))
record.args = tuple(args)
record.args = type(record.args)(final_args)
elif isinstance(record.args, dict):
for key, arg in record.args.items():
if not isinstance(arg, basestring):