lcpfs 2026.1.102

LCP File System - A ZFS-inspired copy-on-write filesystem for Rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
// Copyright 2025 LunaOS Contributors
// SPDX-License-Identifier: Apache-2.0

//! Log and history viewing for branches.
//!
//! This module provides git-log style functionality for viewing
//! commit history, file history, and branch graphs.

use alloc::string::{String, ToString};
use alloc::vec;
use alloc::vec::Vec;

use super::commit::CommitStore;
use super::types::{BranchError, ChangeType, Commit, FileChange};

// ═══════════════════════════════════════════════════════════════════════════════
// LOG OPTIONS
// ═══════════════════════════════════════════════════════════════════════════════

/// Options for log output.
#[derive(Debug, Clone)]
pub struct LogOptions {
    /// Maximum number of commits to show.
    pub limit: Option<usize>,
    /// Skip first N commits.
    pub skip: usize,
    /// Only show commits affecting this path.
    pub path_filter: Option<String>,
    /// Only show commits by this author.
    pub author_filter: Option<String>,
    /// Only show commits after this timestamp.
    pub since: Option<u64>,
    /// Only show commits before this timestamp.
    pub until: Option<u64>,
    /// Show file changes in each commit.
    pub show_changes: bool,
    /// Format for output.
    pub format: LogFormat,
}

impl Default for LogOptions {
    fn default() -> Self {
        Self {
            limit: None,
            skip: 0,
            path_filter: None,
            author_filter: None,
            since: None,
            until: None,
            show_changes: false,
            format: LogFormat::Medium,
        }
    }
}

impl LogOptions {
    /// Create options showing the last N commits.
    pub fn last(n: usize) -> Self {
        Self {
            limit: Some(n),
            ..Default::default()
        }
    }

    /// Set the limit.
    pub fn with_limit(mut self, n: usize) -> Self {
        self.limit = Some(n);
        self
    }

    /// Set the skip count.
    pub fn with_skip(mut self, n: usize) -> Self {
        self.skip = n;
        self
    }

    /// Filter by path.
    pub fn with_path(mut self, path: impl Into<String>) -> Self {
        self.path_filter = Some(path.into());
        self
    }

    /// Filter by author.
    pub fn with_author(mut self, author: impl Into<String>) -> Self {
        self.author_filter = Some(author.into());
        self
    }

    /// Filter by date range.
    pub fn with_date_range(mut self, since: Option<u64>, until: Option<u64>) -> Self {
        self.since = since;
        self.until = until;
        self
    }

    /// Show file changes.
    pub fn with_changes(mut self) -> Self {
        self.show_changes = true;
        self
    }

    /// Set the output format.
    pub fn with_format(mut self, format: LogFormat) -> Self {
        self.format = format;
        self
    }
}

/// Log output format.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogFormat {
    /// One line per commit.
    Oneline,
    /// Short format (hash, author, message).
    Short,
    /// Medium format (includes date).
    Medium,
    /// Full format (all details).
    Full,
    /// Custom format.
    Custom,
}

// ═══════════════════════════════════════════════════════════════════════════════
// LOG ENTRY
// ═══════════════════════════════════════════════════════════════════════════════

/// A log entry representing a commit in history.
#[derive(Debug, Clone)]
pub struct LogEntry {
    /// Commit hash (full).
    pub hash: [u8; 32],
    /// Short hash.
    pub short_hash: String,
    /// Commit message.
    pub message: String,
    /// Author.
    pub author: String,
    /// Timestamp.
    pub timestamp: u64,
    /// TXG.
    pub txg: u64,
    /// Number of files changed.
    pub files_changed: usize,
    /// File changes (if requested).
    pub changes: Option<Vec<FileChange>>,
    /// Is this a merge commit?
    pub is_merge: bool,
    /// Branch names pointing to this commit.
    pub branches: Vec<String>,
}

impl LogEntry {
    /// Create from a commit.
    pub fn from_commit(commit: &Commit, include_changes: bool) -> Self {
        Self {
            hash: commit.hash,
            short_hash: commit.short_hash(),
            message: commit.message.clone(),
            author: commit.author.clone(),
            timestamp: commit.timestamp,
            txg: commit.txg,
            files_changed: commit.changes.len(),
            changes: if include_changes {
                Some(commit.changes.clone())
            } else {
                None
            },
            is_merge: Self::detect_merge_commit(commit),
            branches: Vec::new(),
        }
    }

    /// Detect if a commit is a merge commit.
    ///
    /// A commit is considered a merge commit if its message starts with "Merge "
    /// (case-insensitive). This follows the convention used by git and other VCS.
    fn detect_merge_commit(commit: &Commit) -> bool {
        let msg_lower = commit.message.to_lowercase();
        msg_lower.starts_with("merge ")
            || msg_lower.starts_with("merge:")
            || msg_lower.starts_with("merged ")
    }

    /// Format as oneline.
    pub fn format_oneline(&self) -> String {
        alloc::format!("{} {}", self.short_hash, self.first_line())
    }

    /// Format as short.
    pub fn format_short(&self) -> String {
        alloc::format!(
            "commit {}\nAuthor: {}\n\n    {}\n",
            self.short_hash,
            self.author,
            self.first_line()
        )
    }

    /// Format as medium.
    pub fn format_medium(&self) -> String {
        alloc::format!(
            "commit {}\nAuthor: {}\nDate:   {}\n\n    {}\n",
            self.short_hash,
            self.author,
            format_timestamp(self.timestamp),
            self.first_line()
        )
    }

    /// Format as full.
    pub fn format_full(&self) -> String {
        let mut output = alloc::format!(
            "commit {}\nAuthor: {}\nDate:   {}\nTXG:    {}\n\n    {}\n",
            hex_string(&self.hash),
            self.author,
            format_timestamp(self.timestamp),
            self.txg,
            self.message.replace('\n', "\n    ")
        );

        if let Some(ref changes) = self.changes {
            output.push_str("\n    Files changed:\n");
            for change in changes {
                output.push_str(&alloc::format!(
                    "        {} {}\n",
                    change.change_type.short_name(),
                    change.path
                ));
            }
        }

        output
    }

    /// Get the first line of the message.
    fn first_line(&self) -> &str {
        self.message.lines().next().unwrap_or(&self.message)
    }

    /// Format according to options.
    pub fn format(&self, format: LogFormat) -> String {
        match format {
            LogFormat::Oneline => self.format_oneline(),
            LogFormat::Short => self.format_short(),
            LogFormat::Medium => self.format_medium(),
            LogFormat::Full => self.format_full(),
            LogFormat::Custom => self.format_medium(), // Default to medium
        }
    }
}

/// Convert bytes to hex string.
fn hex_string(bytes: &[u8]) -> String {
    let mut s = String::with_capacity(bytes.len() * 2);
    for byte in bytes {
        s.push_str(&alloc::format!("{:02x}", byte));
    }
    s
}

/// Format timestamp as human-readable date.
fn format_timestamp(ts: u64) -> String {
    // Simple formatting - in production, use proper date library
    let days_since_epoch = ts / 86400;
    let time_of_day = ts % 86400;
    let hours = time_of_day / 3600;
    let minutes = (time_of_day % 3600) / 60;
    let seconds = time_of_day % 60;

    // Very rough date calculation (ignoring leap years, etc.)
    let year = 1970 + (days_since_epoch / 365);
    let day_of_year = days_since_epoch % 365;
    let month = day_of_year / 30 + 1;
    let day = day_of_year % 30 + 1;

    alloc::format!(
        "{:04}-{:02}-{:02} {:02}:{:02}:{:02}",
        year,
        month.min(12),
        day.min(31),
        hours,
        minutes,
        seconds
    )
}

// ═══════════════════════════════════════════════════════════════════════════════
// LOG ITERATOR
// ═══════════════════════════════════════════════════════════════════════════════

/// Iterator over log entries.
pub struct LogIterator<'a> {
    commits: Vec<&'a Commit>,
    position: usize,
    options: LogOptions,
    skipped: usize,
    returned: usize,
}

impl<'a> LogIterator<'a> {
    /// Create a new log iterator.
    pub fn new(commits: Vec<&'a Commit>, options: LogOptions) -> Self {
        Self {
            commits,
            position: 0,
            options,
            skipped: 0,
            returned: 0,
        }
    }

    /// Check if commit passes filters.
    fn passes_filters(&self, commit: &Commit) -> bool {
        // Author filter
        if let Some(ref author) = self.options.author_filter {
            if !commit.author.contains(author) {
                return false;
            }
        }

        // Time filters
        if let Some(since) = self.options.since {
            if commit.timestamp < since {
                return false;
            }
        }
        if let Some(until) = self.options.until {
            if commit.timestamp > until {
                return false;
            }
        }

        // Path filter
        if let Some(ref path) = self.options.path_filter {
            let has_path = commit.changes.iter().any(|c| c.path.contains(path));
            if !has_path {
                return false;
            }
        }

        true
    }
}

impl<'a> Iterator for LogIterator<'a> {
    type Item = LogEntry;

    fn next(&mut self) -> Option<Self::Item> {
        // Check limit
        if let Some(limit) = self.options.limit {
            if self.returned >= limit {
                return None;
            }
        }

        while self.position < self.commits.len() {
            let commit = self.commits[self.position];
            self.position += 1;

            // Check filters
            if !self.passes_filters(commit) {
                continue;
            }

            // Handle skip
            if self.skipped < self.options.skip {
                self.skipped += 1;
                continue;
            }

            self.returned += 1;
            return Some(LogEntry::from_commit(commit, self.options.show_changes));
        }

        None
    }
}

// ═══════════════════════════════════════════════════════════════════════════════
// LOG VIEWER
// ═══════════════════════════════════════════════════════════════════════════════

/// Log viewer for browsing commit history.
pub struct LogViewer<'a> {
    store: &'a CommitStore,
}

impl<'a> LogViewer<'a> {
    /// Create a new log viewer.
    pub fn new(store: &'a CommitStore) -> Self {
        Self { store }
    }

    /// Get log for a branch.
    pub fn log(&self, branch: &str, options: LogOptions) -> LogIterator<'a> {
        let commits = self.store.branch_commits(branch, None);
        LogIterator::new(commits, options)
    }

    /// Get log starting from a specific commit.
    pub fn log_from(&self, hash: &[u8; 32], options: LogOptions) -> LogIterator<'a> {
        let commits = self.store.ancestry(hash, None);
        LogIterator::new(commits, options)
    }

    /// Get log for a range of commits.
    pub fn log_range(
        &self,
        start: &[u8; 32],
        end: &[u8; 32],
        options: LogOptions,
    ) -> LogIterator<'a> {
        let commits = self.store.range(Some(start), end);
        LogIterator::new(commits, options)
    }

    /// Get file history.
    pub fn file_history(&self, branch: &str, path: &str) -> Vec<LogEntry> {
        let options = LogOptions::default().with_path(path).with_changes();
        self.log(branch, options).collect()
    }

    /// Count commits in a branch.
    pub fn count(&self, branch: &str) -> usize {
        self.store.branch_commits(branch, None).len()
    }

    /// Get statistics for a branch.
    pub fn stats(&self, branch: &str) -> BranchStats {
        let commits = self.store.branch_commits(branch, None);

        let mut total_additions = 0usize;
        let mut total_deletions = 0usize;
        let mut total_modifications = 0usize;
        let mut authors = Vec::new();

        for commit in &commits {
            // Count change types
            for change in &commit.changes {
                match change.change_type {
                    ChangeType::Created => total_additions += 1,
                    ChangeType::Deleted => total_deletions += 1,
                    ChangeType::Modified => total_modifications += 1,
                    ChangeType::Renamed { .. } => {}
                }
            }

            // Collect unique authors
            if !authors.contains(&commit.author) {
                authors.push(commit.author.clone());
            }
        }

        let first_commit = commits.last();
        let last_commit = commits.first();

        BranchStats {
            commit_count: commits.len(),
            total_additions,
            total_deletions,
            total_modifications,
            author_count: authors.len(),
            first_commit_date: first_commit.map(|c| c.timestamp),
            last_commit_date: last_commit.map(|c| c.timestamp),
        }
    }

    /// Get shortlog (commit count per author).
    pub fn shortlog(&self, branch: &str) -> Vec<(String, usize)> {
        let commits = self.store.branch_commits(branch, None);
        let mut counts: alloc::collections::BTreeMap<String, usize> =
            alloc::collections::BTreeMap::new();

        for commit in commits {
            *counts.entry(commit.author.clone()).or_insert(0) += 1;
        }

        let mut result: Vec<_> = counts.into_iter().collect();
        result.sort_by(|a, b| b.1.cmp(&a.1)); // Sort by count descending
        result
    }
}

/// Branch statistics.
#[derive(Debug, Clone)]
pub struct BranchStats {
    /// Total number of commits.
    pub commit_count: usize,
    /// Total file additions.
    pub total_additions: usize,
    /// Total file deletions.
    pub total_deletions: usize,
    /// Total file modifications.
    pub total_modifications: usize,
    /// Number of unique authors.
    pub author_count: usize,
    /// First commit date.
    pub first_commit_date: Option<u64>,
    /// Last commit date.
    pub last_commit_date: Option<u64>,
}

// ═══════════════════════════════════════════════════════════════════════════════
// GRAPH VISUALIZATION
// ═══════════════════════════════════════════════════════════════════════════════

/// Simple graph representation for branch visualization.
#[derive(Debug, Clone)]
pub struct CommitGraph {
    /// Nodes in the graph.
    pub nodes: Vec<GraphNode>,
}

/// A node in the commit graph.
#[derive(Debug, Clone)]
pub struct GraphNode {
    /// Commit hash.
    pub hash: [u8; 32],
    /// Column position (for ASCII art).
    pub column: usize,
    /// Parent connections.
    pub parents: Vec<GraphEdge>,
    /// Branch labels.
    pub branches: Vec<String>,
}

/// An edge in the commit graph.
#[derive(Debug, Clone)]
pub struct GraphEdge {
    /// Parent hash.
    pub parent_hash: [u8; 32],
    /// Parent column.
    pub parent_column: usize,
}

impl CommitGraph {
    /// Build a graph from commits.
    pub fn build(commits: &[&Commit]) -> Self {
        let mut nodes = Vec::new();

        for (i, commit) in commits.iter().enumerate() {
            let parents = if let Some(parent_hash) = commit.parent {
                // Find parent in commits
                let parent_col = commits
                    .iter()
                    .position(|c| c.hash == parent_hash)
                    .unwrap_or(0);
                vec![GraphEdge {
                    parent_hash,
                    parent_column: 0, // Simplified - single column
                }]
            } else {
                vec![]
            };

            nodes.push(GraphNode {
                hash: commit.hash,
                column: 0, // Simplified - single column
                parents,
                branches: vec![],
            });
        }

        Self { nodes }
    }

    /// Render as ASCII art.
    pub fn render_ascii(&self, commits: &[&Commit]) -> Vec<String> {
        let mut lines = Vec::new();

        for (i, node) in self.nodes.iter().enumerate() {
            let commit = commits.get(i);
            let prefix = if node.parents.is_empty() { "* " } else { "| " };

            if let Some(c) = commit {
                lines.push(alloc::format!(
                    "{}  {} {}",
                    prefix,
                    c.short_hash(),
                    first_line(&c.message)
                ));
            }
        }

        lines
    }
}

/// Get the first line of a string.
fn first_line(s: &str) -> &str {
    s.lines().next().unwrap_or(s)
}

// ═══════════════════════════════════════════════════════════════════════════════
// TESTS
// ═══════════════════════════════════════════════════════════════════════════════

#[cfg(test)]
mod tests {
    use super::*;
    use crate::branch::commit::CommitBuilder;

    fn create_test_store() -> CommitStore {
        let mut store = CommitStore::new();

        let c1 = CommitBuilder::new(100)
            .message("Initial commit")
            .author("alice@example.com")
            .timestamp(1704067200)
            .change(FileChange::created("/README.md".into(), [1; 4], 100))
            .build();

        let c2 = CommitBuilder::new(101)
            .parent(c1.hash)
            .message("Add feature")
            .author("bob@example.com")
            .timestamp(1704153600)
            .change(FileChange::created("/feature.rs".into(), [2; 4], 200))
            .build();

        let c3 = CommitBuilder::new(102)
            .parent(c2.hash)
            .message("Fix bug")
            .author("alice@example.com")
            .timestamp(1704240000)
            .change(FileChange::modified(
                "/feature.rs".into(),
                [2; 4],
                [3; 4],
                200,
                210,
            ))
            .build();

        store.add_commit(c1);
        store.add_commit(c2);
        store.add_commit_to_branch(c3, "main");

        store
    }

    #[test]
    fn test_log_default() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let entries: Vec<_> = viewer.log("main", LogOptions::default()).collect();

        assert_eq!(entries.len(), 3);
        assert_eq!(entries[0].message, "Fix bug");
        assert_eq!(entries[2].message, "Initial commit");
    }

    #[test]
    fn test_log_limit() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let entries: Vec<_> = viewer.log("main", LogOptions::last(2)).collect();

        assert_eq!(entries.len(), 2);
    }

    #[test]
    fn test_log_skip() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let entries: Vec<_> = viewer
            .log("main", LogOptions::default().with_skip(1))
            .collect();

        assert_eq!(entries.len(), 2);
        assert_eq!(entries[0].message, "Add feature");
    }

    #[test]
    fn test_log_author_filter() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let entries: Vec<_> = viewer
            .log("main", LogOptions::default().with_author("alice"))
            .collect();

        assert_eq!(entries.len(), 2);
        for entry in entries {
            assert!(entry.author.contains("alice"));
        }
    }

    #[test]
    fn test_log_path_filter() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let entries: Vec<_> = viewer
            .log("main", LogOptions::default().with_path("feature"))
            .collect();

        assert_eq!(entries.len(), 2); // Add feature + Fix bug
    }

    #[test]
    fn test_file_history() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let history = viewer.file_history("main", "/feature.rs");

        assert_eq!(history.len(), 2);
        assert!(history[0].changes.is_some());
    }

    #[test]
    fn test_stats() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let stats = viewer.stats("main");

        assert_eq!(stats.commit_count, 3);
        assert_eq!(stats.total_additions, 2);
        assert_eq!(stats.total_modifications, 1);
        assert_eq!(stats.author_count, 2);
    }

    #[test]
    fn test_shortlog() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        let shortlog = viewer.shortlog("main");

        assert_eq!(shortlog.len(), 2);
        // Alice has 2 commits
        let alice = shortlog.iter().find(|(a, _)| a.contains("alice"));
        assert!(alice.is_some());
        assert_eq!(alice.unwrap().1, 2);
    }

    #[test]
    fn test_log_entry_format_oneline() {
        let commit = CommitBuilder::new(100)
            .message("Test commit\nWith multiple lines")
            .author("test")
            .timestamp(1704067200)
            .build();

        let entry = LogEntry::from_commit(&commit, false);
        let oneline = entry.format_oneline();

        assert!(oneline.contains(&entry.short_hash));
        assert!(oneline.contains("Test commit"));
        assert!(!oneline.contains("With multiple lines"));
    }

    #[test]
    fn test_log_entry_format_full() {
        let commit = CommitBuilder::new(100)
            .message("Test commit")
            .author("test@example.com")
            .timestamp(1704067200)
            .change(FileChange::created("/file.txt".into(), [1; 4], 100))
            .build();

        let entry = LogEntry::from_commit(&commit, true);
        let full = entry.format_full();

        assert!(full.contains("test@example.com"));
        assert!(full.contains("TXG:    100"));
        assert!(full.contains("/file.txt"));
    }

    #[test]
    fn test_count() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        assert_eq!(viewer.count("main"), 3);
        assert_eq!(viewer.count("nonexistent"), 0);
    }

    #[test]
    fn test_graph_build() {
        let store = create_test_store();
        let commits = store.branch_commits("main", None);
        let graph = CommitGraph::build(&commits);

        assert_eq!(graph.nodes.len(), 3);
    }

    #[test]
    fn test_format_timestamp() {
        let ts = format_timestamp(1704067200);
        assert!(ts.contains("2024")); // Approximate year
    }

    #[test]
    fn test_log_date_filter() {
        let store = create_test_store();
        let viewer = LogViewer::new(&store);

        // Only commits after the first one
        let entries: Vec<_> = viewer
            .log(
                "main",
                LogOptions::default().with_date_range(Some(1704100000), None),
            )
            .collect();

        assert_eq!(entries.len(), 2);
    }
}