Commit 6c04ee3ea292fc0f2e21951f181d308691ba4487
1 parent
49e13337
logger: replace newline in messages with simple space
pypy's json loader does not accept newlines in strings
Showing
1 changed file
with
1 additions
and
1 deletions
oletools/common/log_helper/_json_formatter.py
| @@ -18,7 +18,7 @@ class JsonFormatter(logging.Formatter): | @@ -18,7 +18,7 @@ class JsonFormatter(logging.Formatter): | ||
| 18 | ensures that there is a `type` field in the record. Otherwise will have | 18 | ensures that there is a `type` field in the record. Otherwise will have |
| 19 | to add a try-except around the access to `record.type`. | 19 | to add a try-except around the access to `record.type`. |
| 20 | """ | 20 | """ |
| 21 | - json_dict = dict(msg=record.msg, level=record.levelname) | 21 | + json_dict = dict(msg=record.msg.replace('\n', ' '), level=record.levelname) |
| 22 | json_dict['type'] = record.type | 22 | json_dict['type'] = record.type |
| 23 | formatted_message = ' ' + json.dumps(json_dict) | 23 | formatted_message = ' ' + json.dumps(json_dict) |
| 24 | 24 |