Add proper logging
This commit is contained in:
@@ -3,7 +3,6 @@ package dav
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -11,10 +10,14 @@ import (
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/dav"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
)
|
||||
|
||||
func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.TorrentManager, c config.ConfigInterface, cache *expirable.LRU[string, string]) {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("dav")
|
||||
|
||||
requestPath := path.Clean(r.URL.Path)
|
||||
requestPath = strings.Trim(requestPath, "/")
|
||||
|
||||
@@ -38,13 +41,13 @@ func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.To
|
||||
case len(filteredSegments) == 2:
|
||||
output, err = handleSingleTorrent(requestPath, w, r, t)
|
||||
default:
|
||||
log.Println("Not Found", r.Method, requestPath)
|
||||
log.Errorf("Request %s %s not found", r.Method, requestPath)
|
||||
writeHTTPError(w, "Not Found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error processing request: %v\n", err)
|
||||
log.Errorf("Error processing request: %v", err)
|
||||
writeHTTPError(w, "Server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dav
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -9,7 +8,6 @@ import (
|
||||
func convertRFC3339toRFC1123(input string) string {
|
||||
t, err := time.Parse(time.RFC3339, input)
|
||||
if err != nil {
|
||||
log.Println("Conversion error", err)
|
||||
return ""
|
||||
}
|
||||
return t.Format("Mon, 02 Jan 2006 15:04:05 GMT")
|
||||
|
||||
Reference in New Issue
Block a user