logs
This commit is contained in:
parent
1dbb38b822
commit
90328d56b0
14
main.go
14
main.go
@ -142,7 +142,7 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
go func(directory *DirectoryConfig, monitoredEvents []notify.Event) {
|
go func(directory *DirectoryConfig, monitoredEvents []notify.Event) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
log.Printf("watching %s for %v, regex %s\n", directory.Path, directory.Events, *directory.Regex)
|
log.Printf("[ INFO ] path=\"%s\" watching=\"%v\" regex \"%s\"\n", directory.Path, directory.Events, *directory.Regex)
|
||||||
|
|
||||||
if err := notify.Watch(directory.Path, c, monitoredEvents...); err != nil {
|
if err := notify.Watch(directory.Path, c, monitoredEvents...); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -170,7 +170,7 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
if eventInfo.Event() == 0 {
|
if eventInfo.Event() == 0 {
|
||||||
eventStr = "POLLING"
|
eventStr = "POLLING"
|
||||||
}
|
}
|
||||||
log.Printf("path: %s; event: %s\n", p, eventStr)
|
log.Printf("[ INFO ] path=\"%s\" event=\"%s\"\n", p, eventStr)
|
||||||
if directory._regex != nil {
|
if directory._regex != nil {
|
||||||
directory._regexMatches = directory._regex.FindStringSubmatch(p)
|
directory._regexMatches = directory._regex.FindStringSubmatch(p)
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("path: %s; no regex match\n", p)
|
log.Printf("[ INFO ] path=\"%s\" info=\"no regex match\"\n", p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
// polling only while queue is empty
|
// polling only while queue is empty
|
||||||
files, err := ioutil.ReadDir(directory.Path)
|
files, err := ioutil.ReadDir(directory.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("path: %s; polling error: %s", directory.Path, err)
|
log.Printf("[ ERROR ] path=\"%s\" polling=\"true\" error=\"%s\"", directory.Path, err)
|
||||||
}
|
}
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
p := directory.Path + "/" + f.Name()
|
p := directory.Path + "/" + f.Name()
|
||||||
@ -205,7 +205,7 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("path: %s; no regex match (polling)\n", p)
|
log.Printf("[ INFO ] path=\"%s\" polling=\"true\" info=\"no regex match\"\n", p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
|
|||||||
add2Ctx(action, ctx, "action", action)
|
add2Ctx(action, ctx, "action", action)
|
||||||
|
|
||||||
contin = !action.Stop
|
contin = !action.Stop
|
||||||
log.Printf("path: %s; action: %s; stop: %v\n", eventInfo.Path(), action.Id, !contin)
|
log.Printf("[ INFO ] path=\"%s\" action=\"%s\" stop=\"%v\"\n", eventInfo.Path(), action.Id, !contin)
|
||||||
|
|
||||||
switch action.Type {
|
switch action.Type {
|
||||||
case "http":
|
case "http":
|
||||||
@ -244,7 +244,7 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
|
|||||||
add2Ctx(action, ctx, "error", err.Error())
|
add2Ctx(action, ctx, "error", err.Error())
|
||||||
action.Error = err
|
action.Error = err
|
||||||
|
|
||||||
log.Printf("path: %s; action: %s; error %s", eventInfo.Path(), action.Id, err)
|
log.Printf("[ ERROR ] path=\"%s\" action=\"%s\" error=\"%s\"", eventInfo.Path(), action.Id, err)
|
||||||
for _, aE := range action.OnError {
|
for _, aE := range action.OnError {
|
||||||
aE.Directory = action.Directory
|
aE.Directory = action.Directory
|
||||||
aE.Parent = action
|
aE.Parent = action
|
||||||
|
Loading…
Reference in New Issue
Block a user