aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authoriaz1607 <iaz1607@yandex-team.com>2024-08-19 12:11:45 +0300
committeriaz1607 <iaz1607@yandex-team.com>2024-08-19 12:31:31 +0300
commit00cef8844cbc80b523354f3eba55fb3ea390570b (patch)
treec79d091fd54bce67fbcd0502e62a9f77ec7c5d5e /library
parent212b9b68a6d82b2a1fba894c4440b278571f0a74 (diff)
downloadydb-00cef8844cbc80b523354f3eba55fb3ea390570b.tar.gz
Customize bt colorization
221e27d03ecf65a066e77e452326e20c49e89df5
Diffstat (limited to 'library')
-rw-r--r--library/python/cores/__init__.py38
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)