mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
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")
|
.help("Restart the process if it's still running")
|
||||||
.short("r")
|
.short("r")
|
||||||
.long("restart"))
|
.long("restart"))
|
||||||
.arg(Arg::with_name("verbose")
|
.arg(Arg::with_name("debug")
|
||||||
.help("Prints diagnostic messages")
|
.help("Print debugging messages to stderr")
|
||||||
.short("v")
|
.short("d")
|
||||||
.long("verbose"))
|
.long("debug"))
|
||||||
.arg(Arg::with_name("filter")
|
.arg(Arg::with_name("filter")
|
||||||
.help("Ignore all modifications except those matching the pattern")
|
.help("Ignore all modifications except those matching the pattern")
|
||||||
.short("f")
|
.short("f")
|
||||||
@ -74,10 +74,10 @@ fn get_args<'a>() -> ArgMatches<'a> {
|
|||||||
.get_matches()
|
.get_matches()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logger(verbose: bool) {
|
fn init_logger(debug: bool) {
|
||||||
let mut log_builder = env_logger::LogBuilder::new();
|
let mut log_builder = env_logger::LogBuilder::new();
|
||||||
let mut level = log::LogLevelFilter::Warn;
|
let mut level = log::LogLevelFilter::Warn;
|
||||||
if verbose {
|
if debug {
|
||||||
level = log::LogLevelFilter::Debug;
|
level = log::LogLevelFilter::Debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ fn init_logger(verbose: bool) {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let args = get_args();
|
let args = get_args();
|
||||||
|
|
||||||
init_logger(args.is_present("verbose"));
|
init_logger(args.is_present("debug"));
|
||||||
|
|
||||||
let cwd = env::current_dir()
|
let cwd = env::current_dir()
|
||||||
.expect("unable to get cwd")
|
.expect("unable to get cwd")
|
||||||
@ -167,7 +167,6 @@ fn wait(rx: &Receiver<Event>, filter: &NotificationFilter) -> Result<Event, Recv
|
|||||||
let e = try!(rx.recv());
|
let e = try!(rx.recv());
|
||||||
if let Some(ref path) = e.path {
|
if let Some(ref path) = e.path {
|
||||||
if filter.is_excluded(&path) {
|
if filter.is_excluded(&path) {
|
||||||
debug!("Ignoring {} due to filter", path.to_str().unwrap());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,16 @@ impl NotificationFilter {
|
|||||||
pub fn is_excluded(&self, path: &Path) -> bool {
|
pub fn is_excluded(&self, path: &Path) -> bool {
|
||||||
let path_as_str = path.to_str().unwrap();
|
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 {
|
for pattern in &self.ignores {
|
||||||
if pattern.matches(path_as_str) {
|
if pattern.matches(path_as_str) {
|
||||||
|
debug!("Ignoring {:?}: matched ignore filter", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,10 +103,15 @@ impl NotificationFilter {
|
|||||||
|
|
||||||
if let Some(ref ignore_file) = self.ignore_file {
|
if let Some(ref ignore_file) = self.ignore_file {
|
||||||
if ignore_file.is_excluded(path) {
|
if ignore_file.is_excluded(path) {
|
||||||
|
debug!("Ignoring {:?}: matched gitignore file", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.filters.len() > 0 {
|
||||||
|
debug!("Ignoring {:?}: did not match any given filters", path);
|
||||||
|
}
|
||||||
|
|
||||||
self.filters.len() > 0
|
self.filters.len() > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,11 @@ impl Runner {
|
|||||||
pub fn run_command(&mut self, cmd: &str) {
|
pub fn run_command(&mut self, cmd: &str) {
|
||||||
if let Some(ref mut child) = self.process {
|
if let Some(ref mut child) = self.process {
|
||||||
if self.restart {
|
if self.restart {
|
||||||
|
debug!("Killing child process (pid: {})", child.id());
|
||||||
let _ = child.kill();
|
let _ = child.kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("Waiting for child process (pid: {})", child.id());
|
||||||
let _ = child.wait();
|
let _ = child.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user