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
//! A log reader library that provides real-time streaming of file contents.
//!
//! This library monitors files for changes and emits new content as an async stream,
//! with handling of file appends by tracking read positions.
//!
//! # Example
//!
//! ```rust,no_run
//! use log_reader::watch_log;
//! use tokio_stream::StreamExt;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut stream = watch_log("app.log", None).await?;
//!
//! while let Some(lines) = stream.next().await {
//! match lines {
//! Ok(content) => {
//! for line in content {
//! println!("New line: {}", line);
//! }
//! }
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//!
//! Ok(())
//! }
//! ```
// Internal modules - not part of public API
// Public API exports
pub use ;
pub use LogStream;
use Path;
use Stream;
/// Creates a stream that watches a file for new content.
///
/// # Arguments
///
/// * `path` - File path to monitor
/// * `separator` - Content separator (defaults to newline)
///
/// # Example
///
/// ```rust,no_run
/// use log_reader::watch_log;
/// use tokio_stream::StreamExt;
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut stream = watch_log("app.log", None).await?;
///
/// while let Some(lines) = stream.next().await {
/// for line in lines? {
/// println!("New line: {}", line);
/// }
/// }
///
/// Ok(())
/// }
/// ```
pub async