Skip to content

Commit

Permalink
Show all fsnotify events with --verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
cespare committed Apr 26, 2014
1 parent 100e2b8 commit 8247234
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func walker(watcher *fsnotify.Watcher) filepath.WalkFunc {
}
if err := watcher.Watch(path); err != nil {
// TODO: handle this somehow?
infoPrintf(-1, "Error while watching new path %s: %s\n", path, err)
infoPrintf(-1, "Error while watching new path %s: %s", path, err)
}
return nil
}
Expand All @@ -63,18 +63,21 @@ func broadcast(in <-chan string, outs []chan<- string) {
func watch(root string, watcher *fsnotify.Watcher, names chan<- string, done chan<- error) {
if err := filepath.Walk(root, walker(watcher)); err != nil {
// TODO: handle this somehow?
infoPrintf(-1, "Error while walking path %s: %s\n", root, err)
infoPrintf(-1, "Error while walking path %s: %s", root, err)
}

for {
select {
case e := <-watcher.Event:
path := strings.TrimPrefix(e.Name, "./")
if verbose {
infoPrintln(-1, "fsnotify event:", e)
}
names <- path
if e.IsCreate() {
if err := filepath.Walk(path, walker(watcher)); err != nil {
// TODO: handle this somehow?
infoPrintf(-1, "Error while walking path %s: %s\n", path, err)
infoPrintf(-1, "Error while walking path %s: %s", path, err)
}
}
if e.IsDelete() {
Expand Down Expand Up @@ -282,7 +285,9 @@ func printMsg(msg OutMsg, writer io.Writer) {
if decoration == DecorationFancy {
fmt.Fprintf(writer, "\x1b[m")
}
fmt.Fprintln(writer)
if !strings.HasSuffix(msg.message, "\n") {
fmt.Fprintln(writer)
}
}

func printOutput(out <-chan OutMsg, outWriter io.Writer) {
Expand Down

0 comments on commit 8247234

Please sign in to comment.