logwatcher/src/main.rs
noyez 6f8f9bd75d
Change closure from Fn to FnMut. (#5)
* 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>
2020-08-21 12:12:11 +05:30

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
});
}