Skip to content

Commit

Permalink
Merge branch 'improve_editor_support'
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Jul 24, 2021
2 parents 946582f + 3c70ab4 commit 999ee19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/gaze/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/wtetsu/gaze/pkg/logger"
)

const version = "v0.1.8"
const version = "v1.0.1"

func main() {
args := app.ParseArgs(os.Args, func() {
Expand Down
21 changes: 17 additions & 4 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package logger
import (
"fmt"
"os"
"sync"

"github.com/fatih/color"
)
Expand All @@ -31,6 +32,8 @@ var printError func(format string, a ...interface{})

var initialized = false

var mutex = &sync.Mutex{}

func initialize() {
if initialized {
return
Expand Down Expand Up @@ -74,8 +77,10 @@ func Error(format string, a ...interface{}) {
if logLevel < QUIET {
return
}
mutex.Lock()
defer mutex.Unlock()
initialize()
space()
newLine()
printError(format, a...)
fmt.Println()
count++
Expand Down Expand Up @@ -105,11 +110,15 @@ func notice(enableSpace bool, format string, a ...interface{}) {
if logLevel < NORMAL {
return
}
mutex.Lock()
defer mutex.Unlock()
initialize()
if enableSpace {
space()
newLine()
printNotice(format, a...)
} else {
printNotice(format, a...)
}
printNotice(format, a...)
fmt.Println()
count++
}
Expand All @@ -119,6 +128,8 @@ func Info(format string, a ...interface{}) {
if logLevel < VERBOSE {
return
}
mutex.Lock()
defer mutex.Unlock()
initialize()
printInfo(format, a...)
fmt.Println()
Expand All @@ -130,6 +141,8 @@ func Debug(format string, a ...interface{}) {
if logLevel < DEBUG {
return
}
mutex.Lock()
defer mutex.Unlock()
initialize()
fmt.Printf(format, a...)
fmt.Println()
Expand All @@ -141,7 +154,7 @@ func DebugObject(a ...interface{}) {
Debug("%v", a...)
}

func space() {
func newLine() {
count++
if count <= 1 {
return
Expand Down
5 changes: 4 additions & 1 deletion pkg/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func New(patterns []string) (*Notify, error) {
times: make(map[string]int64),
pendingPeriod: 100,
regardRenameAsModPeriod: 1000,
detectCreate: false,
detectCreate: true,
}

go notify.wait()
Expand All @@ -100,14 +100,17 @@ func (n *Notify) wait() {
for {
select {
case event, ok := <-n.watcher.Events:

normalizedName := filepath.Clean(event.Name)

if !ok {
continue
}
if !n.shouldExecute(normalizedName, event.Op) {
logger.Debug("notified: %s: %s (skipped)", event.Name, event.Op)
continue
}
logger.Debug("notified: %s: %s (skipped)", event.Name, event.Op)
now := time.Now()
n.times[normalizedName] = now
e := Event{
Expand Down

0 comments on commit 999ee19

Please sign in to comment.