This commit is contained in:
Sebastian Frank 2021-08-12 17:28:41 +02:00
parent 1dbb38b822
commit 90328d56b0
Signed by: apairon
GPG Key ID: A0E05A8199CE3F57

14
main.go
View File

@ -142,7 +142,7 @@ func startWatcher(directory *DirectoryConfig) {
go func(directory *DirectoryConfig, monitoredEvents []notify.Event) {
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 {
log.Fatal(err)
@ -170,7 +170,7 @@ func startWatcher(directory *DirectoryConfig) {
if eventInfo.Event() == 0 {
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 {
directory._regexMatches = directory._regex.FindStringSubmatch(p)
}
@ -183,7 +183,7 @@ func startWatcher(directory *DirectoryConfig) {
}
}
} 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
files, err := ioutil.ReadDir(directory.Path)
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 {
p := directory.Path + "/" + f.Name()
@ -205,7 +205,7 @@ func startWatcher(directory *DirectoryConfig) {
default:
}
} 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)
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 {
case "http":
@ -244,7 +244,7 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
add2Ctx(action, ctx, "error", err.Error())
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 {
aE.Directory = action.Directory
aE.Parent = action