diff options
author | AlexSm <alex@ydb.tech> | 2024-08-19 16:16:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-19 17:16:30 +0300 |
commit | 9b567afd3339f4525feab53873592cb025b14251 (patch) | |
tree | 5c8489f98dc5a9a10f66065055e5a401bbd14767 /library/python/cores | |
parent | 47bd121575c210d4bbb2dddcc2131759a694df05 (diff) | |
download | ydb-9b567afd3339f4525feab53873592cb025b14251.tar.gz |
Library import 240819-0942 (#7994)
Co-authored-by: robot-piglet <robot-piglet@yandex-team.com>
Co-authored-by: hiddenpath <hiddenpath@yandex-team.com>
Co-authored-by: bulatman <bulatman@yandex-team.com>
Co-authored-by: robot-contrib <robot-contrib@yandex-team.com>
Co-authored-by: osidorkin <osidorkin@yandex-team.com>
Co-authored-by: akhropov <akhropov@yandex-team.com>
Co-authored-by: akozhikhov <akozhikhov@yandex-team.com>
Co-authored-by: orlovorlov <orlovorlov@yandex-team.com>
Co-authored-by: babenko <babenko@yandex-team.com>
Co-authored-by: shadchin <shadchin@yandex-team.com>
Co-authored-by: dmasloff <dmasloff@yandex-team.com>
Co-authored-by: aleksei-le <aleksei-le@yandex-team.com>
Co-authored-by: coteeq <coteeq@yandex-team.com>
Co-authored-by: dimdim11 <dimdim11@yandex-team.com>
Co-authored-by: robot-ya-builder <robot-ya-builder@yandex-team.com>
Co-authored-by: iaz1607 <iaz1607@yandex-team.com>
Diffstat (limited to 'library/python/cores')
-rw-r--r-- | library/python/cores/__init__.py | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/library/python/cores/__init__.py b/library/python/cores/__init__.py index f5b1bb2478..8c10c0128b 100644 --- a/library/python/cores/__init__.py +++ b/library/python/cores/__init__.py @@ -162,21 +162,45 @@ def get_problem_stack(backtrace): return "\n".join(stack) +BT_COLORS = { + "function_name": "[[c:cyan]]", + "function_arg": "[[c:green]]", + "stack_frame": "[[c:red]]", + "thread_prefix": "[[c:light-cyan]]", + "thread_id": "[[c:red]]", + "file_path": "[[c:light-grey]]", + "line_num": "[[c:magenta]]", + "address": "[[c:light-grey]]", +} + + # XXX -def colorize_backtrace(text): +def colorize_backtrace(text, c=None): + if c is None: + c = BT_COLORS + filters = [ # Function names and the class they belong to - (re.compile(r"^(#[0-9]+ .*?)([a-zA-Z0-9_:\.@]+)(\s?\()", flags=re.MULTILINE), r"\1[[c:cyan]]\2[[rst]]\3"), + ( + re.compile(r"^(#[0-9]+ .*?)([a-zA-Z0-9_:\.@]+)(\s?\()", flags=re.MULTILINE), + r"\1" + c['function_name'] + r"\2[[rst]]\3", + ), # Function argument names - (re.compile(r"([a-zA-Z0-9_#]*)(\s?=\s?)"), r"[[c:green]]\1[[rst]]\2"), + (re.compile(r"([a-zA-Z0-9_#]*)(\s?=\s?)"), c["function_arg"] + r"\1[[rst]]\2"), # Stack frame number - (re.compile(r"^(#[0-9]+)", flags=re.MULTILINE), r"[[c:red]]\1[[rst]]"), + (re.compile(r"^(#[0-9]+)", flags=re.MULTILINE), c["stack_frame"] + r"\1[[rst]]"), # Thread id colorization - (re.compile(r"^([ \*]) ([0-9]+)", flags=re.MULTILINE), r"[[c:light-cyan]]\1 [[c:red]]\2[[rst]]"), + ( + re.compile(r"^([ \*]) ([0-9]+)", flags=re.MULTILINE), + c["thread_prefix"] + r"\1 " + c["thread_id"] + r"\2[[rst]]", + ), # File path and line number - (re.compile(r"(\.*[/A-Za-z0-9\+_\.\-]*):(([0-9]+)(:[0-9]+)?)$", flags=re.MULTILINE), r"[[c:light-grey]]\1[[rst]]:[[c:magenta]]\2[[rst]]"), + ( + re.compile(r"(\.*[/A-Za-z0-9\+_\.\-]*):(([0-9]+)(:[0-9]+)?)$", flags=re.MULTILINE), + c["file_path"] + r"\1[[rst]]:" + c["line_num"] + r"\2[[rst]]", + ), # Addresses - (re.compile(r"\b(0x[a-f0-9]{6,})\b"), r"[[c:light-grey]]\1[[rst]]"), + (re.compile(r"\b(0x[a-f0-9]{6,})\b"), c["address"] + r"\1[[rst]]"), ] text = six.ensure_str(text) |