diff --git a/dau.go b/dau.go index ae2830a..2536ad4 100644 --- a/dau.go +++ b/dau.go @@ -64,7 +64,7 @@ func main() { func startWatchers(config *config.ConfigService, up *upload.Uploader, configChange chan bool) { for { - log.Printf("Creating watchers") + daulog.SendLog("Creating watchers", daulog.LogTypeInfo) ctx, cancel := context.WithCancel(context.Background()) for _, c := range config.Config.Watchers { log.Printf("Creating watcher for %s interval %d", c.Path, config.Config.WatchInterval) @@ -74,7 +74,7 @@ func startWatchers(config *config.ConfigService, up *upload.Uploader, configChan // wait for single that the config changed <-configChange cancel() - log.Printf("starting new watchers due to config change") + daulog.SendLog("starting new watchers due to config change", daulog.LogTypeInfo) } } @@ -83,7 +83,7 @@ func (w *watch) Watch(interval int, ctx context.Context) { for { select { case <-ctx.Done(): - log.Printf("Killing old watcher") + daulog.SendLog("Killing old watcher", daulog.LogTypeInfo) return default: newFiles := w.ProcessNewFiles() @@ -123,11 +123,11 @@ func (w *watch) ProcessNewFiles() []string { func (w *watch) checkPath() bool { src, err := os.Stat(w.config.Path) if err != nil { - log.Printf("Problem with path '%s': %s", w.config.Path, err) + daulog.SendLog(fmt.Sprintf("Problem with path '%s': %s", w.config.Path, err), daulog.LogTypeError) return false } if !src.IsDir() { - log.Printf("Problem with path '%s': is not a directory", w.config.Path) + daulog.SendLog(fmt.Sprintf("Problem with path '%s': is not a directory", w.config.Path), daulog.LogTypeError) return false } return true @@ -212,7 +212,6 @@ func checkUpdates() { } daulog.SendLog("already running latest version", daulog.LogTypeInfo) - } func parseOptions() { diff --git a/upload/upload.go b/upload/upload.go index c32e132..1a34b25 100644 --- a/upload/upload.go +++ b/upload/upload.go @@ -188,7 +188,7 @@ func (u *Upload) processUpload() { } if retriesRemaining == 0 { - log.Fatal("Failed to upload, even after retries") + daulog.SendLog("Failed to upload, even after all retries", daulog.LogTypeError) } } @@ -233,7 +233,7 @@ func (u *Upload) applyWatermark() { im, _, err := image.Decode(reader) if err != nil { - log.Printf("Cannot decode image: %v - skipping watermarking", err) + daulog.SendLog(fmt.Sprintf("Cannot decode image: %v - skipping watermarking", err), daulog.LogTypeError) u.watermark = false u.filenameToUpload = u.originalFilename return diff --git a/web/server.go b/web/server.go index 906d4e4..c0381fb 100644 --- a/web/server.go +++ b/web/server.go @@ -45,15 +45,13 @@ func (ws *WebService) getStatic(w http.ResponseWriter, r *http.Request) { if extension == ".html" { // html file t, err := template.ParseFS(webFS, "data/wrapper.tmpl", "data/"+path) if err != nil { - log.Printf("when fetching: %s got: %s", path, err) + daulog.SendLog(fmt.Sprintf("when fetching: %s got: %s", path, err), daulog.LogTypeError) w.Header().Add("Content-Type", "text/plain") w.WriteHeader(http.StatusNotFound) w.Write([]byte("not found")) return } - log.Printf("req: %s", r.URL.Path) - var b struct { Body string Path string @@ -71,7 +69,7 @@ func (ws *WebService) getStatic(w http.ResponseWriter, r *http.Request) { otherStatic, err := webFS.ReadFile("data/" + path) if err != nil { - log.Printf("when fetching: %s got: %s", path, err) + daulog.SendLog(fmt.Sprintf("when fetching: %s got: %s", path, err), daulog.LogTypeError) w.Header().Add("Content-Type", "text/plain") w.WriteHeader(http.StatusNotFound) w.Write([]byte("not found"))