Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TypeError for JSONFormatter and udp2log_host
Summary: Currently, in the case where `getMessage()` is called on a LogRecord created by `JSONFormatter.make_record` it will fail. This is because `JSONFormatter` treats args as a list instead of a tuple. If there are actual args for use in the msg format string, `getMessage()` will call: record.msg % record.args This will fail with something like: '%s %s' % ['hello', 'world'] TypeError: not enough arguments for format string Which is what happens inside the LogstashFormatter when a command fails on a remote and the log record is propogated to Logstash. This shadows the actual error message with: File "/mnt/srv/deployment/scap/scap/scap/log.py", line 180, in format fields['message'] = fields['msg'] % fields['args'] TypeError: not enough arguments for format string Change-Id: I1c7360009e89aac9ab60ec5e84a4ded6af20a950 Test Plan: On scap-vagrant: - inside `scap/scap.cfg` set `udp2log_host: localhost` - chown some files on the targets to create errors - the final error should NOT be `TypeError: not enough arguments for format string` Reviewers: demon, mmodell, #release-engineering-team, dduvall Reviewed By: mmodell, #release-engineering-team, dduvall Subscribers: jenkins Differential Revision: https://phabricator.wikimedia.org/D83
- Loading branch information