Skip to main content

compact

Function compact 

Source
pub fn compact(input: &str, remove_timestamps: bool) -> String
Expand description

Compacts a log by collapsing runs of three or more adjacent identical lines into first-occurrence / [repeated Nx] / last-occurrence (three output lines total, regardless of run length). See the module-level doc comment for the full behavioral contract, including the adjacent-only limitation and the >=3 threshold.

ยงParameters

  • input: raw log text as \n-separated lines (a trailing newline is not required).
  • remove_timestamps: when true, a recognized leading timestamp (ISO-8601 or syslog-style) is stripped from every line before run-detection, and the stripped form is what appears in the output. When false (the default), timestamps are never touched, so two lines identical except for their timestamp are treated as distinct.