|
1 | 1 | use async_trait::async_trait; |
2 | 2 | use serde::{Deserialize, Serialize}; |
3 | | -use slog::{warn, Logger}; |
| 3 | +use slog::{Logger, warn}; |
4 | 4 | use std::cmp::Reverse; |
5 | 5 | use std::collections::BinaryHeap; |
6 | 6 | use std::fs::File; |
@@ -30,17 +30,17 @@ impl FileLogStore { |
30 | 30 | }; |
31 | 31 |
|
32 | 32 | // Run cleanup on startup for all existing log files |
33 | | - if retention_hours > 0 { |
34 | | - if let Ok(entries) = std::fs::read_dir(&store.directory) { |
35 | | - for entry in entries.filter_map(Result::ok) { |
36 | | - let path = entry.path(); |
37 | | - |
38 | | - // Only process .jsonl files |
39 | | - if path.extension().and_then(|s| s.to_str()) == Some("jsonl") { |
40 | | - // Run cleanup, but don't fail initialization if cleanup fails |
41 | | - if let Err(e) = store.cleanup_old_logs(&path) { |
42 | | - eprintln!("Warning: Failed to cleanup old logs for {:?}: {}", path, e); |
43 | | - } |
| 33 | + if retention_hours > 0 |
| 34 | + && let Ok(entries) = std::fs::read_dir(&store.directory) |
| 35 | + { |
| 36 | + for entry in entries.filter_map(Result::ok) { |
| 37 | + let path = entry.path(); |
| 38 | + |
| 39 | + // Only process .jsonl files |
| 40 | + if path.extension().and_then(|s| s.to_str()) == Some("jsonl") { |
| 41 | + // Run cleanup, but don't fail initialization if cleanup fails |
| 42 | + if let Err(e) = store.cleanup_old_logs(&path) { |
| 43 | + eprintln!("Warning: Failed to cleanup old logs for {:?}: {}", path, e); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -98,30 +98,30 @@ impl FileLogStore { |
98 | 98 | /// Check if an entry matches the query filters |
99 | 99 | fn matches_filters(&self, entry: &LogEntry, query: &LogQuery) -> bool { |
100 | 100 | // Level filter |
101 | | - if let Some(level) = query.level { |
102 | | - if entry.level != level { |
103 | | - return false; |
104 | | - } |
| 101 | + if let Some(level) = query.level |
| 102 | + && entry.level != level |
| 103 | + { |
| 104 | + return false; |
105 | 105 | } |
106 | 106 |
|
107 | 107 | // Time range filters |
108 | | - if let Some(ref from) = query.from { |
109 | | - if entry.timestamp < *from { |
110 | | - return false; |
111 | | - } |
| 108 | + if let Some(ref from) = query.from |
| 109 | + && entry.timestamp < *from |
| 110 | + { |
| 111 | + return false; |
112 | 112 | } |
113 | 113 |
|
114 | | - if let Some(ref to) = query.to { |
115 | | - if entry.timestamp > *to { |
116 | | - return false; |
117 | | - } |
| 114 | + if let Some(ref to) = query.to |
| 115 | + && entry.timestamp > *to |
| 116 | + { |
| 117 | + return false; |
118 | 118 | } |
119 | 119 |
|
120 | 120 | // Text search (case-insensitive) |
121 | | - if let Some(ref search) = query.search { |
122 | | - if !entry.text.to_lowercase().contains(&search.to_lowercase()) { |
123 | | - return false; |
124 | | - } |
| 121 | + if let Some(ref search) = query.search |
| 122 | + && !entry.text.to_lowercase().contains(&search.to_lowercase()) |
| 123 | + { |
| 124 | + return false; |
125 | 125 | } |
126 | 126 |
|
127 | 127 | true |
|
0 commit comments