MCPcopy Index your code
hub / github.com/tinode/chat / clip_long_string

Function clip_long_string

chatbot/python/chatbot.py:62–72  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

60
61# Shorten long strings for logging.
62def 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
74def to_json(msg):
75 return json.dumps(clip_long_string(MessageToDict(msg)))

Callers 1

to_jsonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…