Enhance debug output; rename option back to debug
This commit is contained in:
parent
392aea8ca3
commit
536613852f
15
src/main.rs
15
src/main.rs
|
@ -48,10 +48,10 @@ fn get_args<'a>() -> ArgMatches<'a> {
|
|||
.help("Restart the process if it's still running")
|
||||
.short("r")
|
||||
.long("restart"))
|
||||
.arg(Arg::with_name("verbose")
|
||||
.help("Prints diagnostic messages")
|
||||
.short("v")
|
||||
.long("verbose"))
|
||||
.arg(Arg::with_name("debug")
|
||||
.help("Print debugging messages to stderr")
|
||||
.short("d")
|
||||
.long("debug"))
|
||||
.arg(Arg::with_name("filter")
|
||||
.help("Ignore all modifications except those matching the pattern")
|
||||
.short("f")
|
||||
|
@ -74,10 +74,10 @@ fn get_args<'a>() -> ArgMatches<'a> {
|
|||
.get_matches()
|
||||
}
|
||||
|
||||
fn init_logger(verbose: bool) {
|
||||
fn init_logger(debug: bool) {
|
||||
let mut log_builder = env_logger::LogBuilder::new();
|
||||
let mut level = log::LogLevelFilter::Warn;
|
||||
if verbose {
|
||||
if debug {
|
||||
level = log::LogLevelFilter::Debug;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ fn init_logger(verbose: bool) {
|
|||
fn main() {
|
||||
let args = get_args();
|
||||
|
||||
init_logger(args.is_present("verbose"));
|
||||
init_logger(args.is_present("debug"));
|
||||
|
||||
let cwd = env::current_dir()
|
||||
.expect("unable to get cwd")
|
||||
|
@ -167,7 +167,6 @@ fn wait(rx: &Receiver<Event>, filter: &NotificationFilter) -> Result<Event, Recv
|
|||
let e = try!(rx.recv());
|
||||
if let Some(ref path) = e.path {
|
||||
if filter.is_excluded(&path) {
|
||||
debug!("Ignoring {} due to filter", path.to_str().unwrap());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,16 @@ impl NotificationFilter {
|
|||
pub fn is_excluded(&self, path: &Path) -> bool {
|
||||
let path_as_str = path.to_str().unwrap();
|
||||
|
||||
if let Ok(metadata) = path.metadata() {
|
||||
if metadata.is_dir() {
|
||||
debug!("Ignoring {:?}: is a directory", path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for pattern in &self.ignores {
|
||||
if pattern.matches(path_as_str) {
|
||||
debug!("Ignoring {:?}: matched ignore filter", path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +103,15 @@ impl NotificationFilter {
|
|||
|
||||
if let Some(ref ignore_file) = self.ignore_file {
|
||||
if ignore_file.is_excluded(path) {
|
||||
debug!("Ignoring {:?}: matched gitignore file", path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.filters.len() > 0 {
|
||||
debug!("Ignoring {:?}: did not match any given filters", path);
|
||||
}
|
||||
|
||||
self.filters.len() > 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,11 @@ impl Runner {
|
|||
pub fn run_command(&mut self, cmd: &str) {
|
||||
if let Some(ref mut child) = self.process {
|
||||
if self.restart {
|
||||
debug!("Killing child process (pid: {})", child.id());
|
||||
let _ = child.kill();
|
||||
}
|
||||
|
||||
debug!("Waiting for child process (pid: {})", child.id());
|
||||
let _ = child.wait();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue