From f115b2256d4baaf3bd79522d0ed5c100431256f0 Mon Sep 17 00:00:00 2001 From: simulot Date: Thu, 31 Aug 2023 08:33:46 +0200 Subject: [PATCH] wip: better debug output --- immich/assets/googlephotos.go | 19 ++++++++++--------- immich/assets/localfile.go | 12 +++++++++--- immich/logger/logger.go | 7 +++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/immich/assets/googlephotos.go b/immich/assets/googlephotos.go index b9a4bb73..1f884add 100644 --- a/immich/assets/googlephotos.go +++ b/immich/assets/googlephotos.go @@ -80,15 +80,16 @@ func (fsys *GooglePhotosAssetBrowser) Browse(ctx context.Context) chan *LocalAss } f := LocalAssetFile{ - FSys: fsys, - FileName: path.Join(dir, nameReplacer.Replace(md.Title)), - Title: md.Title, - Trashed: md.Trashed, - FromPartner: md.GooglePhotosOrigin.FromPartnerSharing != nil, - DateTaken: md.PhotoTakenTime.Time(), - Latitude: md.GeoData.Latitude, - Longitude: md.GeoData.Longitude, - Altitude: md.GeoData.Altitude, + FSys: fsys, + FileName: path.Join(dir, nameReplacer.Replace(md.Title)), + Title: md.Title, + Trashed: md.Trashed, + FromPartner: md.GooglePhotosOrigin.FromPartnerSharing != nil, + DateTaken: md.PhotoTakenTime.Time(), + Latitude: md.GeoData.Latitude, + Longitude: md.GeoData.Longitude, + Altitude: md.GeoData.Altitude, + MetadataFile: name, } if album, ok := fsys.albums[dir]; ok { diff --git a/immich/assets/localfile.go b/immich/assets/localfile.go index 6925ad6e..8981fa53 100644 --- a/immich/assets/localfile.go +++ b/immich/assets/localfile.go @@ -42,9 +42,10 @@ type LocalAssetFile struct { Altitude float64 // GPS Altitude // Google Photos flags - Trashed bool // The asset is trashed - Archived bool // The asset is archived - FromPartner bool // the asset comes from a partner + Trashed bool // The asset is trashed + Archived bool // The asset is archived + FromPartner bool // the asset comes from a partner + MetadataFile string FSys fs.FS // Asset's file system @@ -64,6 +65,11 @@ type LocalAssetFile struct { reader io.Reader // the reader that combines the partial read and original file for full file reading } +func (l LocalAssetFile) DebugObject() any { + l.FSys = nil + return l +} + // partialSourceReader open a reader on the current asset. // each byte read from it is saved into a temporary file. // diff --git a/immich/logger/logger.go b/immich/logger/logger.go index 2b2237d0..179205c4 100644 --- a/immich/logger/logger.go +++ b/immich/logger/logger.go @@ -83,10 +83,17 @@ func (l *Logger) Debug(f string, v ...any) { l.Message(Debug, f, v...) } +type DebugObject interface { + DebugObject() any +} + func (l *Logger) DebugObject(name string, v any) { if Debug > l.displayLevel { return } + if d, ok := v.(DebugObject); ok { + v = d.DebugObject() + } b := bytes.NewBuffer(nil) enc := json.NewEncoder(b) enc.SetIndent("", " ")