mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-06 02:28:56 +00:00
integration-tests: show logs in sorted order
We were collecting the logs, printing them as we found them, and then returning the sorted result. That made it awkward for a human to review, so what we do now is defer printing the logged records until after we have sorted them. For records with the same timestamp, we sort based on the message id and the record type so that there is some additional consistency and to make it easier to reason about.
This commit is contained in:
@@ -484,8 +484,6 @@ impl KumoDaemon {
|
||||
let entry = entry?;
|
||||
if entry.file_type()?.is_file() {
|
||||
let text = read_zstd_file_with_retry(&entry.path())?;
|
||||
eprintln!("{text}");
|
||||
|
||||
for line in text.lines() {
|
||||
let record: JsonLogRecord = serde_json::from_str(&line)?;
|
||||
records.push(record);
|
||||
@@ -493,7 +491,22 @@ impl KumoDaemon {
|
||||
}
|
||||
}
|
||||
|
||||
records.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
|
||||
records.sort_by(|a, b| {
|
||||
use std::cmp::Ordering;
|
||||
match a.timestamp.cmp(&b.timestamp) {
|
||||
Ordering::Equal => match a.id.cmp(&b.id) {
|
||||
Ordering::Equal => a.kind.cmp(&b.kind),
|
||||
r => r,
|
||||
},
|
||||
r => r,
|
||||
}
|
||||
});
|
||||
|
||||
// and print it in the sorted order for easier understanding
|
||||
for r in &records {
|
||||
eprintln!("{}", serde_json::to_string(r).unwrap());
|
||||
}
|
||||
|
||||
Ok(records)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user