Skip to content
Snippets Groups Projects
  • Raymond Cheung's avatar
    Ensure Logs Are Captured for Assertions and Printed During Tests (#7769) · ce5f89c6
    Raymond Cheung authored
    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>
    Unverified
    ce5f89c6
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
This project manages its dependencies using Cargo. Learn more