Log -> Navidrome.Log

This commit is contained in:
Rob Emery 2025-01-11 12:35:57 +00:00
parent 151092661c
commit 03eae403b4

View File

@ -5,7 +5,6 @@ package dlna
import ( import (
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"log"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -18,6 +17,7 @@ import (
"github.com/anacrolix/dms/upnp" "github.com/anacrolix/dms/upnp"
"github.com/navidrome/navidrome/conf" "github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/dlna/upnpav" "github.com/navidrome/navidrome/dlna/upnpav"
"github.com/navidrome/navidrome/log"
) )
type contentDirectoryService struct { type contentDirectoryService struct {
@ -77,7 +77,7 @@ func (cds *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, is
// Returns all the upnpav objects in a directory. // Returns all the upnpav objects in a directory.
func (cds *contentDirectoryService) readContainer(o object, host string) (ret []interface{}, err error) { func (cds *contentDirectoryService) readContainer(o object, host string) (ret []interface{}, err error) {
log.Printf("ReadContainer called with : %+v", o) log.Info(fmt.Sprintf("ReadContainer called with : %+v", o))
//TODO implement HTTP routing rather than this //TODO implement HTTP routing rather than this
switch o.Path { switch o.Path {
@ -163,7 +163,6 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
if strings.HasPrefix(o.Path, "/Music/Files/") { if strings.HasPrefix(o.Path, "/Music/Files/") {
libraryPath, _ := strings.CutPrefix(o.Path, "/Music/Files") libraryPath, _ := strings.CutPrefix(o.Path, "/Music/Files")
log.Printf("library path: %s", libraryPath)
files, _ := os.ReadDir(path.Join(conf.Server.MusicFolder, libraryPath)) files, _ := os.ReadDir(path.Join(conf.Server.MusicFolder, libraryPath))
for _, file := range files { for _, file := range files {
child := object{ child := object{
@ -186,7 +185,8 @@ type browse struct {
// ContentDirectory object from ObjectID. // ContentDirectory object from ObjectID.
func (cds *contentDirectoryService) objectFromID(id string) (o object, err error) { func (cds *contentDirectoryService) objectFromID(id string) (o object, err error) {
log.Printf("objectFromID Called: %+v", id) log.Info(fmt.Sprintf("objectFromID called with : %+v", id))
o.Path, err = url.QueryUnescape(id) o.Path, err = url.QueryUnescape(id)
if err != nil { if err != nil {
return return
@ -204,7 +204,8 @@ func (cds *contentDirectoryService) objectFromID(id string) (o object, err error
func (cds *contentDirectoryService) Handle(action string, argsXML []byte, r *http.Request) (map[string]string, error) { func (cds *contentDirectoryService) Handle(action string, argsXML []byte, r *http.Request) (map[string]string, error) {
host := r.Host host := r.Host
log.Printf("Handle called with action: %s", action) log.Info(fmt.Sprintf("Handle called with action: %s", action))
switch action { switch action {
case "GetSystemUpdateID": case "GetSystemUpdateID":
return map[string]string{ return map[string]string{
@ -293,7 +294,7 @@ func (o *object) FilePath() string {
// Returns the ObjectID for the object. This is used in various ContentDirectory actions. // Returns the ObjectID for the object. This is used in various ContentDirectory actions.
func (o object) ID() string { func (o object) ID() string {
if !path.IsAbs(o.Path) { if !path.IsAbs(o.Path) {
log.Panicf("Relative object path: %s", o.Path) log.Fatal(fmt.Sprintf("Relative object path used with ID: $s", o.Path))
} }
if len(o.Path) == 1 { if len(o.Path) == 1 {
return "0" return "0"