Clean up logging
This commit is contained in:
parent
3776374747
commit
ec8b2453cd
11
dau.go
11
dau.go
@ -64,7 +64,7 @@ func main() {
|
|||||||
|
|
||||||
func startWatchers(config *config.ConfigService, up *upload.Uploader, configChange chan bool) {
|
func startWatchers(config *config.ConfigService, up *upload.Uploader, configChange chan bool) {
|
||||||
for {
|
for {
|
||||||
log.Printf("Creating watchers")
|
daulog.SendLog("Creating watchers", daulog.LogTypeInfo)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
for _, c := range config.Config.Watchers {
|
for _, c := range config.Config.Watchers {
|
||||||
log.Printf("Creating watcher for %s interval %d", c.Path, config.Config.WatchInterval)
|
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
|
// wait for single that the config changed
|
||||||
<-configChange
|
<-configChange
|
||||||
cancel()
|
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 {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
log.Printf("Killing old watcher")
|
daulog.SendLog("Killing old watcher", daulog.LogTypeInfo)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
newFiles := w.ProcessNewFiles()
|
newFiles := w.ProcessNewFiles()
|
||||||
@ -123,11 +123,11 @@ func (w *watch) ProcessNewFiles() []string {
|
|||||||
func (w *watch) checkPath() bool {
|
func (w *watch) checkPath() bool {
|
||||||
src, err := os.Stat(w.config.Path)
|
src, err := os.Stat(w.config.Path)
|
||||||
if err != nil {
|
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
|
return false
|
||||||
}
|
}
|
||||||
if !src.IsDir() {
|
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 false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -212,7 +212,6 @@ func checkUpdates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
daulog.SendLog("already running latest version", daulog.LogTypeInfo)
|
daulog.SendLog("already running latest version", daulog.LogTypeInfo)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseOptions() {
|
func parseOptions() {
|
||||||
|
@ -188,7 +188,7 @@ func (u *Upload) processUpload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if retriesRemaining == 0 {
|
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)
|
im, _, err := image.Decode(reader)
|
||||||
if err != nil {
|
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.watermark = false
|
||||||
u.filenameToUpload = u.originalFilename
|
u.filenameToUpload = u.originalFilename
|
||||||
return
|
return
|
||||||
|
@ -45,15 +45,13 @@ func (ws *WebService) getStatic(w http.ResponseWriter, r *http.Request) {
|
|||||||
if extension == ".html" { // html file
|
if extension == ".html" { // html file
|
||||||
t, err := template.ParseFS(webFS, "data/wrapper.tmpl", "data/"+path)
|
t, err := template.ParseFS(webFS, "data/wrapper.tmpl", "data/"+path)
|
||||||
if err != nil {
|
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.Header().Add("Content-Type", "text/plain")
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
w.Write([]byte("not found"))
|
w.Write([]byte("not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("req: %s", r.URL.Path)
|
|
||||||
|
|
||||||
var b struct {
|
var b struct {
|
||||||
Body string
|
Body string
|
||||||
Path string
|
Path string
|
||||||
@ -71,7 +69,7 @@ func (ws *WebService) getStatic(w http.ResponseWriter, r *http.Request) {
|
|||||||
otherStatic, err := webFS.ReadFile("data/" + path)
|
otherStatic, err := webFS.ReadFile("data/" + path)
|
||||||
|
|
||||||
if err != nil {
|
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.Header().Add("Content-Type", "text/plain")
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
w.Write([]byte("not found"))
|
w.Write([]byte("not found"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user