Remove Loguru color formatting#8079
Conversation
Replace colored sink formats and message markup with plain text, then delete the escaping and trailing-backslash handling that Loguru colors required. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea7056a8-6011-4c84-b93d-099bb9b8094f
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea7056a8-6011-4c84-b93d-099bb9b8094f
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea7056a8-6011-4c84-b93d-099bb9b8094f
There was a problem hiding this comment.
Pull request overview
This PR removes Loguru color/markup usage from the Python test infrastructure and switches logging output to a plain-text format with compact, aligned level display and optional severity markers. This fits into the test/infra tooling by simplifying log rendering and avoiding markup parsing overhead and escaping complexity.
Changes:
- Removed
colors=Trueusage and Loguru color tags from test/infra logging call sites and sink formats. - Introduced a shared
format_log_record()formatter to render compact 4-character level labels in key test runners. - Removed the Loguru tag-escaping helper and updated request/response rendering to plain text.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/suite/test_requirements.py | Removes colored “Test:” banner logging. |
| tests/start_network.py | Switches stdout sink format to plain text. |
| tests/infra/runner.py | Uses shared callable formatter for runner stdout logs. |
| tests/infra/piccolo/analyzer.py | Removes color tags from analyzer output formats. |
| tests/infra/log_capture.py | Drops colors=True when flushing captured lines. |
| tests/infra/e2e_args.py | Adds shared compact level/marker formatter and uses it as default sink format. |
| tests/infra/clients.py | Removes Loguru tag escaping and switches request/response string rendering to plain text. |
| tests/governance.py | Removes colored “Test:” log line in single-node governance run. |
| tests/fuzzing.py | Stops escaping sent/received fuzzing log lines for Loguru markup. |
| tests/cleanup_iptables.py | Switches stdout sink format to plain text. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Fixed in 513b525. I pulled in the |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Fixed in 3455a0d. I aligned |
Summary
TRC,DBG,INFO,SUCC,WARN,ERR, andCRITThis is an experimental alternative to #8078. The goal is to compare the simpler plain-text path with hardening the existing colored-markup path. No tests are added by this PR.
Scope and complexity
The repository-wide audit found 16 explicit Loguru color/markup sites across 10 files. After this change, searches for
colors=True,colorize=, Loguru color tags, and the escaping helper return no production matches.Before adding the requested compact level display and severity markers, the color-removal diff was 19 additions and 39 deletions: 20 fewer lines. The display mapping adds 30 lines, making the final diff 49 additions and 39 deletions: 10 more lines overall. The escaping, status-color, and backslash-workaround simplifications remain.
Visual comparison
These captures use the same intentional assertion at the start of
recovery_snapshot_ledger_offsetagainst the parent revision and the final formatter. The assertion existed only in temporary source copies and is not part of this PR.Measurements
Stored size
A representative client-log workload emitted 100,000 request/response pairs (200,000 info-level lines) using the exact before/after runner formats and request/response message shapes with Loguru 0.7.3.
Loguru already suppresses ANSI sequences for a non-TTY sink, so the non-TTY reduction comes from shortening the level field from eight characters to four. Capturing TTY-colored output stores 4,600,000 ANSI sequences totaling 20,000,000 bytes in this workload.
Rough runtime cost
A local process-CPU microbenchmark emitted 60,000 representative lines per sample into an in-memory counting sink, with 11 repetitions and median results. The final plain path includes the callable formatter that maps level labels and markers.
This is intentionally a rough microbenchmark rather than an application benchmark. It suggests markup parsing remains measurable for short, heavily marked-up client lines, although the level/marker formatter reduces the final plain path's advantage compared with a static plain format.
Recovery workload
For a real test-infrastructure workload, I ran
recovery_snapshot_ledger_offsetfromrecovery_testagainst the same released CCF 7.0.10 binary, once from the parent revision and once with the final formatter. Both runs completed successfully under a pseudo-terminal and emitted exactly 1,168 output records.The final plain capture is 75,136 bytes smaller (22.95%). ANSI sequences account for 70,738 bytes of that reduction; compact level fields and run-specific plain text account for the remaining 4,398-byte net reduction. The final run included 12 success markers. Single-run wall times were too noisy to attribute to formatting, so the isolated repeated microbenchmark above is the runtime comparison.
The matching
VMSS Virtual BCI job and all other required ACI and VMSS jobs passed on the color-removal commit. Fresh CI is running for the final formatting and no-test cleanup. CTest job logs cannot provide a stored-size comparison because successful test stdout is hidden and CTest uses a non-TTY.Validation