Skip to content

Commit

Permalink
wip: better debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
laaqxdze1k committed Aug 31, 2023
1 parent 73787e1 commit f115b22
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
19 changes: 10 additions & 9 deletions immich/assets/googlephotos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions immich/assets/localfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
//
Expand Down
7 changes: 7 additions & 0 deletions immich/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("", " ")
Expand Down

0 comments on commit f115b22

Please sign in to comment.