Switch to a proper logging library

Structured logs can be enabled with `-log.json`.
This commit is contained in:
Conrad Hoffmann 2022-12-01 12:00:42 +01:00
parent 03fce79e57
commit 40bae8dc31
9 changed files with 75 additions and 64 deletions

View file

@ -11,11 +11,11 @@ import (
"regexp"
"strings"
"github.com/rs/zerolog/log"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/caldav"
"github.com/emersion/go-webdav/carddav"
"git.sr.ht/~sircmpwn/tokidoki/debug"
)
type filesystemBackend struct {
@ -83,7 +83,7 @@ func (b *filesystemBackend) safeLocalPath(homeSetPath string, urlPath string) (s
}
// only accept simple file names for now
if !validFilenameRegex.MatchString(file) {
debug.Printf("%s does not match regex!\n", file)
log.Debug().Str("file", file).Msg("file name does not match regex")
err := fmt.Errorf("invalid file name: %s", file)
return "", webdav.NewHTTPError(400, err)
}