* Using FnMut, so works * Using FnMut for watch() and reopen_if_log_rotated() * adding fn to force reopen * adding actions to closure Co-authored-by: noyez <brad@bkn.local> Co-authored-by: noyez <brad@bkn.localdomain> Co-authored-by: Bradley Noyes <b@noyes.dev>
22 lines
488 B
Rust
22 lines
488 B
Rust
use std::env::args;
|
|
use std::process::exit;
|
|
|
|
extern crate logwatcher;
|
|
use logwatcher::{LogWatcher, LogWatcherAction};
|
|
|
|
fn main() {
|
|
let filename = match args().nth(1) {
|
|
Some(x) => x,
|
|
None => {
|
|
println!("File name required");
|
|
exit(1);
|
|
}
|
|
};
|
|
|
|
let mut log_watcher = LogWatcher::register(filename).unwrap();
|
|
|
|
log_watcher.watch(&mut move |line: String| {
|
|
println!("Line {}", line);
|
|
LogWatcherAction::None
|
|
});
|
|
}
|