Skip to content
Snippets Groups Projects
Unverified Commit ce5f89c6 authored by Raymond Cheung's avatar Raymond Cheung Committed by GitHub
Browse files

Ensure Logs Are Captured for Assertions and Printed During Tests (#7769)

This PR enhances **`test_log_capture`**, ensuring logs are **captured
for assertions** and **printed to the console** during test execution.

## **Motivation**  

- Partially addresses #6119 and #6125, to improves developer **tracing
and debugging** in XCM-related tests.
- Builds on #7594, improving **log visibility** while maintaining test
**log capture capabilities**.
- While writing tests for #7234, I noticed this function was missing.
This PR adds it to streamline log handling in unit tests.

## **Changes**  

- Ensures logs up to `TRACE` level are **captured** (for assertions) and
**printed** (for visibility).
- Refines documentation to clearly specify **when to use** each
function.
- **Removes ANSI escape codes** from captured logs to ensure clean,
readable assertions.

## **When to Use?**  

| Usage | Captures Logs? | Prints Logs? | Example |

|----------------------------------------------|-----------------|--------------|-----------------------------------------------|
| `init_log_capture(LevelFilter::INFO, false)` | :white_check_mark: Yes | :x: No | Capture
logs for assertions without printing. |
| `init_log_capture(LevelFilter::TRACE, true)` | :white_check_mark: Yes | :white_check_mark: Yes | Capture
logs and print them in test output. |
| `sp_tracing::init_for_tests()` | :x: No | :white_check_mark:

 Yes | Print logs to the
console without capturing. |

---------

Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
parent f02134c8
No related merge requests found
Pipeline #518086 waiting for manual action with stages
in 1 hour, 6 minutes, and 26 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment