Skip to main content

extract_context

Function extract_context 

Source
pub fn extract_context(
    content: &str,
    config: &LogContextConfig,
) -> LogContextResult
Expand description

Scan content for keyword matches and return surrounding context windows.

Each line is checked for any configured keyword as a substring match. When multiple keywords appear on the same line the first keyword in LogContextConfig::keywords wins. Line numbers in the output are 1-based to match standard editor and log viewer conventions.

This function is allocation-efficient: lines are collected once into a Vec<&str> and context slices reference that vec without additional copies until the final owned Strings are built for the result.