Async log watch

async_log_watch is a simple Rust library developed as a part of a personal project. It is designed to monitor log files and trigger an async callback whenever a new line is added to the file. The library allows users to easily integrate log file monitoring into their projects, with support for monitoring multiple log files simultaneously.

The primary motivation behind creating this library was to efficiently detect new log lines generated by tools like pm2. The library is built using the async-std runtime and the notify crate for file system event monitoring.

Usage

Add async-log-watch to your Cargo.toml dependencies:

toml [dependencies] async-log-watch= "0.1"

Example

```rust use asynclogwatch::{LogWatcher, LogError};

[async_std::main]

async fn main() -> Result<(), Box> { let mut log_watcher = LogWatcher::new();

let filepath = "~/.pm2/logs/r1-out.log";
log_watcher
    .register(filepath, |line: String, err: Option<LogError>| async move {
        if err.is_none() {
            println!("New log line: {}", line);
        } else {
            eprintln!("{}", err.unwrap());
        }
    })
    .await;

log_watcher
    .monitoring(std::time::Duration::from_secs(1))
    .await?;
Ok(())

}

```

TODO

Future Works

License

This project is licensed under the MIT License - see the LICENSE file for details.