Доработка формата html
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "plba"
|
name = "plba"
|
||||||
version = "0.3.10"
|
version = "0.3.11"
|
||||||
description = "Platform runtime for business applications"
|
description = "Platform runtime for business applications"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
@@ -98,18 +98,19 @@ class TraceResponseRenderer:
|
|||||||
:root {{
|
:root {{
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--bg: #000000;
|
--bg: #000000;
|
||||||
--fg: #cfcfc2;
|
--fg: #ececec;
|
||||||
|
--step: #ffffff;
|
||||||
--link: #66d9ef;
|
--link: #66d9ef;
|
||||||
--error: #f92672;
|
--error: #ff817d;
|
||||||
--warning: #e6db74;
|
--warning: #e5801d;
|
||||||
--info: #a6e22e;
|
--info: #73a0cf;
|
||||||
--debug: #ae81ff;
|
--other: #ececec;
|
||||||
}}
|
}}
|
||||||
body {{
|
body {{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--fg);
|
color: var(--fg);
|
||||||
font: 12px/1 "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
|
font: 13px/1.1 "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
|
||||||
}}
|
}}
|
||||||
.page {{
|
.page {{
|
||||||
padding: 14px 16px 24px;
|
padding: 14px 16px 24px;
|
||||||
@@ -133,7 +134,7 @@ class TraceResponseRenderer:
|
|||||||
color: var(--info);
|
color: var(--info);
|
||||||
}}
|
}}
|
||||||
.msg-debug {{
|
.msg-debug {{
|
||||||
color: var(--debug);
|
color: var(--other);
|
||||||
}}
|
}}
|
||||||
@media (max-width: 640px) {{
|
@media (max-width: 640px) {{
|
||||||
.page {{
|
.page {{
|
||||||
@@ -182,12 +183,12 @@ class TraceResponseRenderer:
|
|||||||
for record in trace_view.records:
|
for record in trace_view.records:
|
||||||
current_step = str(record.step or "")
|
current_step = str(record.step or "")
|
||||||
if previous_step is None:
|
if previous_step is None:
|
||||||
lines.append(self._html_plain_line(escape(current_step)))
|
lines.append(self._html_step_line(current_step))
|
||||||
lines.append(self._html_plain_line(""))
|
lines.append(self._html_plain_line(""))
|
||||||
elif current_step != previous_step:
|
elif current_step != previous_step:
|
||||||
lines.append(self._html_plain_line(""))
|
lines.append(self._html_plain_line(""))
|
||||||
lines.append(self._html_plain_line("--------------------------------------------------"))
|
lines.append(self._html_plain_line("--------------------------------------------------"))
|
||||||
lines.append(self._html_plain_line(escape(current_step)))
|
lines.append(self._html_step_line(current_step))
|
||||||
lines.append(self._html_plain_line(""))
|
lines.append(self._html_plain_line(""))
|
||||||
previous_step = current_step
|
previous_step = current_step
|
||||||
lines.extend(self._html_message_lines(record, request.include_attrs_json))
|
lines.extend(self._html_message_lines(record, request.include_attrs_json))
|
||||||
@@ -200,6 +201,9 @@ class TraceResponseRenderer:
|
|||||||
def _html_plain_line(self, content: str) -> str:
|
def _html_plain_line(self, content: str) -> str:
|
||||||
return f"<div class=\"line\">{content or ' '}</div>"
|
return f"<div class=\"line\">{content or ' '}</div>"
|
||||||
|
|
||||||
|
def _html_step_line(self, content: str) -> str:
|
||||||
|
return f"<div class=\"line\" style=\"color: var(--step);\">{escape(content) or ' '}</div>"
|
||||||
|
|
||||||
def _html_colored_line(self, content: str, level: str) -> str:
|
def _html_colored_line(self, content: str, level: str) -> str:
|
||||||
level_class = self._level_class(level)
|
level_class = self._level_class(level)
|
||||||
return f"<div class=\"line {level_class}\">{escape(content)}</div>"
|
return f"<div class=\"line {level_class}\">{escape(content)}</div>"
|
||||||
@@ -219,6 +223,6 @@ class TraceResponseRenderer:
|
|||||||
return "msg-error"
|
return "msg-error"
|
||||||
if level == "WARNING":
|
if level == "WARNING":
|
||||||
return "msg-warning"
|
return "msg-warning"
|
||||||
if level == "DEBUG":
|
if level == "INFO":
|
||||||
return "msg-debug"
|
return "msg-info"
|
||||||
return "msg-info"
|
return "msg-debug"
|
||||||
|
|||||||
@@ -203,16 +203,21 @@ def test_trace_endpoint_returns_html_page_with_related_links() -> None:
|
|||||||
assert response.headers["content-type"].startswith("text/html")
|
assert response.headers["content-type"].startswith("text/html")
|
||||||
assert "background: var(--bg);" in response.text
|
assert "background: var(--bg);" in response.text
|
||||||
assert "--bg: #000000;" in response.text
|
assert "--bg: #000000;" in response.text
|
||||||
assert "--fg: #cfcfc2;" in response.text
|
assert "--fg: #ececec;" in response.text
|
||||||
assert 'font: 12px/1 "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;' in response.text
|
assert "--step: #ffffff;" in response.text
|
||||||
|
assert "--info: #73a0cf;" in response.text
|
||||||
|
assert "--warning: #e5801d;" in response.text
|
||||||
|
assert "--error: #ff817d;" in response.text
|
||||||
|
assert "--other: #ececec;" in response.text
|
||||||
|
assert 'font: 13px/1.1 "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;' in response.text
|
||||||
assert '<div class="line">trace_id: <a href="/traces/trace-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">trace-1</a></div>' in response.text
|
assert '<div class="line">trace_id: <a href="/traces/trace-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">trace-1</a></div>' in response.text
|
||||||
assert '<div class="line">parent_id: <a href="/traces/parent-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">parent-1</a></div>' in response.text
|
assert '<div class="line">parent_id: <a href="/traces/parent-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">parent-1</a></div>' in response.text
|
||||||
assert '<div class="line">child_ids:</div>' in response.text
|
assert '<div class="line">child_ids:</div>' in response.text
|
||||||
assert '<div class="line"> - <a href="/traces/child-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">child-1</a></div>' in response.text
|
assert '<div class="line"> - <a href="/traces/child-1?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">child-1</a></div>' in response.text
|
||||||
assert '<div class="line"> - <a href="/traces/child-2?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">child-2</a></div>' in response.text
|
assert '<div class="line"> - <a href="/traces/child-2?format=html&levels=ERROR%2CWARNING%2CINFO&attrs_json=true">child-2</a></div>' in response.text
|
||||||
assert '<div class="line">load_stocks</div>' in response.text
|
assert '<div class="line" style="color: var(--step);">load_stocks</div>' in response.text
|
||||||
assert '<div class="line">--------------------------------------------------</div>' in response.text
|
assert '<div class="line">--------------------------------------------------</div>' in response.text
|
||||||
assert '<div class="line">filter_stocks</div>' in response.text
|
assert '<div class="line" style="color: var(--step);">filter_stocks</div>' in response.text
|
||||||
assert "loaded prices" in response.text
|
assert "loaded prices" in response.text
|
||||||
assert "filtered suspicious ticker" in response.text
|
assert "filtered suspicious ticker" in response.text
|
||||||
assert "2026-04-28T10:11:12+00:00 | INFO | ok" not in response.text
|
assert "2026-04-28T10:11:12+00:00 | INFO | ok" not in response.text
|
||||||
|
|||||||
Reference in New Issue
Block a user