Skip to content

Commit 8b3480a

Browse files
committed
feat: sort log by date
1 parent 2b59f76 commit 8b3480a

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Diff for: src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ pub fn process_logs_folder(app_state: &mut AppState) -> anyhow::Result<Vec<LogIn
115115
if latest_timestamp > app_state.latest_log_datetime() {
116116
app_state.set_latest_log_datetime(latest_timestamp);
117117
}
118+
119+
// Sort output to show errors in age order
120+
result.sort_by_key(|x| x.date_time);
121+
118122
Ok(result)
119123
}
120124

Diff for: tests/snapshots/log_parsing__output_snapshot-3.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ source: tests/log_parsing.rs
33
expression: msg
44
---
55
---
6+
[Error] 2024-10-15 09:28:45 errors: 1
7+
Cannot open file "/home/bob/missing_file.pdf".; ENOENT: No such file or directory [stat]
8+
---
69
[Error] 2024-11-08 14:09:13 errors: 4
710
Cannot read file "ProfileName:/[email protected]/bob/logs.7z".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]
811
Cannot delete file "/home/bob/logs-ad8f.ffs_tmp".; ENOENT: No such file or directory [unlink]
912
Cannot read file "ProfileName:/[email protected]/bob/log2.7z".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]
1013
Cannot delete file "/home/bob/log2-62c0.ffs_tmp".; ENOENT: No such file or directory [unlink]
1114
---
12-
[Error] 2024-10-15 09:28:45 errors: 1
13-
Cannot open file "/home/bob/missing_file.pdf".; ENOENT: No such file or directory [stat]
14-
---
1515
[Stopped] 2024-11-08 14:50:21 errors: 1
1616
Stopped
1717
---

Diff for: tests/snapshots/log_parsing__output_snapshot.snap

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ expression: logs_infos
44
---
55
[
66
LogInfo(
7-
date_time: "2024-11-08T14:09:13",
7+
date_time: "2024-10-15T09:28:45",
88
abnormal_outcome: Some("[Error]"),
99
errors_and_warnings: [
10-
"Cannot read file \"ProfileName:/[email protected]/bob/logs.7z\".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]",
11-
"Cannot delete file \"/home/bob/logs-ad8f.ffs_tmp\".; ENOENT: No such file or directory [unlink]",
12-
"Cannot read file \"ProfileName:/[email protected]/bob/log2.7z\".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]",
13-
"Cannot delete file \"/home/bob/log2-62c0.ffs_tmp\".; ENOENT: No such file or directory [unlink]",
10+
"Cannot open file \"/home/bob/missing_file.pdf\".; ENOENT: No such file or directory [stat]",
1411
],
1512
),
1613
LogInfo(
17-
date_time: "2024-10-15T09:28:45",
14+
date_time: "2024-11-08T14:09:13",
1815
abnormal_outcome: Some("[Error]"),
1916
errors_and_warnings: [
20-
"Cannot open file \"/home/bob/missing_file.pdf\".; ENOENT: No such file or directory [stat]",
17+
"Cannot read file \"ProfileName:/[email protected]/bob/logs.7z\".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]",
18+
"Cannot delete file \"/home/bob/logs-ad8f.ffs_tmp\".; ENOENT: No such file or directory [unlink]",
19+
"Cannot read file \"ProfileName:/[email protected]/bob/log2.7z\".; CURLE_OPERATION_TIMEDOUT: Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds [curl_easy_perform]",
20+
"Cannot delete file \"/home/bob/log2-62c0.ffs_tmp\".; ENOENT: No such file or directory [unlink]",
2121
],
2222
),
2323
LogInfo(

0 commit comments

Comments
 (0)