(obj)
| 60 | |
| 61 | # Shorten long strings for logging. |
| 62 | def clip_long_string(obj): |
| 63 | if isinstance(obj, unicode) or isinstance(obj, str): |
| 64 | if len(obj) > MAX_LOG_LEN: |
| 65 | return '<' + str(len(obj)) + ' bytes: ' + obj[:12] + '...' + obj[-12:] + '>' |
| 66 | return obj |
| 67 | elif isinstance(obj, (list, tuple)): |
| 68 | return [clip_long_string(item) for item in obj] |
| 69 | elif isinstance(obj, dict): |
| 70 | return dict((key, clip_long_string(val)) for key, val in obj.items()) |
| 71 | else: |
| 72 | return obj |
| 73 | |
| 74 | def to_json(msg): |
| 75 | return json.dumps(clip_long_string(MessageToDict(msg))) |
no outgoing calls
no test coverage detected
searching dependent graphs…