mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
style(artwork): use one log prefix, spelled the way the codebase does
The package logged under three spellings of its own name -- "artwork: " lowercase, "Prune: " and one "Artwork: " -- and the lowercase ones carried lowercase message text, against 568 capitalized to 48 lowercase elsewhere. Prefixing itself is the convention here (Scanner:, API:, Watcher:) and it earns its place: DevLogSourceLine is off by default, so without it a line does not say which subsystem emitted it. So this normalizes the spelling rather than dropping the prefix. Error strings stay lowercase and unprefixed per Go convention.
This commit is contained in:
parent
02b9cc1354
commit
b71a40f654
@ -81,7 +81,7 @@ func fetchArtistImage(ctx context.Context, ag *agents.Agents, gate gateFunc, ar
|
||||
}
|
||||
if isTransientExternal(err) {
|
||||
extErr = true // includes errBreakerOpen and download failures: retry via the next agent
|
||||
log.Debug(ctx, "artwork: external artist-image lookup failed", "agent", a.Name, "artist", ar.Name, err)
|
||||
log.Debug(ctx, "Artwork: External artist-image lookup failed", "agent", a.Name, "artist", ar.Name, err)
|
||||
}
|
||||
}
|
||||
return nil, "", extErr
|
||||
@ -107,7 +107,7 @@ func fetchAlbumImage(ctx context.Context, ag *agents.Agents, gate gateFunc, al m
|
||||
}
|
||||
if isTransientExternal(err) {
|
||||
extErr = true
|
||||
log.Debug(ctx, "artwork: external album-image lookup failed", "agent", a.Name, "album", al.Name, err)
|
||||
log.Debug(ctx, "Artwork: External album-image lookup failed", "agent", a.Name, "album", al.Name, err)
|
||||
}
|
||||
}
|
||||
return nil, "", extErr
|
||||
|
||||
@ -66,7 +66,7 @@ func fromArtistFolder(ctx context.Context, libFS fs.FS, libPath, artistFolder, p
|
||||
// messages so callers see absolute-looking paths consistent with the rest of
|
||||
// the artwork pipeline.
|
||||
func findImageInFolder(ctx context.Context, libFS fs.FS, relFolder, absFolder, pattern string) (io.ReadCloser, string, error) {
|
||||
log.Trace(ctx, "looking for artist image", "pattern", pattern, "folder", absFolder)
|
||||
log.Trace(ctx, "Looking for artist image", "pattern", pattern, "folder", absFolder)
|
||||
globPattern := pattern
|
||||
if relFolder != "." {
|
||||
globPattern = path.Join(escapeGlobLiteral(relFolder), pattern)
|
||||
|
||||
@ -82,7 +82,7 @@ func Backfill(ctx context.Context, ds model.DataStore) (bool, error) {
|
||||
if err := props.Put(consts.ArtConfFingerprintPropertyKey, current); err != nil {
|
||||
return false, err
|
||||
}
|
||||
log.Info(ctx, "Artwork: config fingerprint changed, backfill enqueued")
|
||||
log.Info(ctx, "Artwork: Config fingerprint changed, backfill enqueued")
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ func processItem(ctx context.Context, deps *workerDeps, item model.ArtworkQueueI
|
||||
|
||||
res, err := newResolver(deps.ds, deps.agents, deps.ffmpeg, deps.gate).resolve(ctx, item)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: could not resolve item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Could not resolve item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
if res.reader == nil {
|
||||
@ -88,14 +88,14 @@ func processItem(ctx context.Context, deps *workerDeps, item model.ArtworkQueueI
|
||||
|
||||
data, err := readCapped(res.reader)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: failed to read resolved image", "kind", item.ItemKind, "id", item.ItemID, "source", res.source, err)
|
||||
log.Warn(ctx, "Artwork: Failed to read resolved image", "kind", item.ItemKind, "id", item.ItemID, "source", res.source, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
log.Debug(ctx, "artwork: read resolved image", "kind", item.ItemKind, "id", item.ItemID, "source", res.source, "bytes", len(data))
|
||||
log.Debug(ctx, "Artwork: Read resolved image", "kind", item.ItemKind, "id", item.ItemID, "source", res.source, "bytes", len(data))
|
||||
|
||||
hash, err := HashImage(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: failed to hash image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Failed to hash image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
|
||||
@ -106,18 +106,18 @@ func processItem(ctx context.Context, deps *workerDeps, item model.ArtworkQueueI
|
||||
case errors.Is(err, model.ErrNotFound):
|
||||
art, err = decodeArtwork(ctx, hash, data)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: failed to decode resolved image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Failed to decode resolved image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
default:
|
||||
log.Warn(ctx, "artwork: failed to look up image hash", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Failed to look up image hash", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
art.SizeBytes = int64(len(data))
|
||||
|
||||
ia, err := persist(deps, repo, item, hash, art, res, data)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: failed to persist resolved image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Failed to persist resolved image", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed, nil
|
||||
}
|
||||
got := &acquired{ia: ia, mime: art.Mime, data: data}
|
||||
@ -170,7 +170,7 @@ func writeAbsent(ctx context.Context, repo model.ArtworkRepository, item model.A
|
||||
AttemptedAt: time.Now(),
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: failed to persist absent state", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Failed to persist absent state", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
return outcomeFailed
|
||||
}
|
||||
return outcomeAbsent
|
||||
@ -219,7 +219,7 @@ func decodeArtwork(ctx context.Context, hash string, data []byte) (*model.Artwor
|
||||
xComp, yComp := blurhash.Components(thumb.Bounds().Dx(), thumb.Bounds().Dy())
|
||||
bh, err := blurhash.Encode(thumb, xComp, yComp)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: blurhash encoding failed", "hash", hash, err)
|
||||
log.Warn(ctx, "Artwork: Blurhash encoding failed", "hash", hash, err)
|
||||
bh = ""
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ func prune(ctx context.Context, ds model.DataStore, store *ImageStore) error {
|
||||
return err
|
||||
}
|
||||
if purged > 0 {
|
||||
log.Info(ctx, "Prune: purged dangling item artwork state", "count", purged)
|
||||
log.Info(ctx, "Artwork: Purged dangling item state", "count", purged)
|
||||
}
|
||||
|
||||
// Queue rows for deleted entities would otherwise retry forever (Get -> not found -> failed).
|
||||
@ -28,7 +28,7 @@ func prune(ctx context.Context, ds model.DataStore, store *ImageStore) error {
|
||||
return err
|
||||
}
|
||||
if queuePurged > 0 {
|
||||
log.Info(ctx, "Prune: purged dangling artwork queue rows", "count", queuePurged)
|
||||
log.Info(ctx, "Artwork: Purged dangling queue rows", "count", queuePurged)
|
||||
}
|
||||
|
||||
// One grace cutoff for both the DB orphan check and the file sweep: files younger
|
||||
@ -60,11 +60,11 @@ func prune(ctx context.Context, ds model.DataStore, store *ImageStore) error {
|
||||
// A spared fresh file is at worst a stray a later sweep reclaims;
|
||||
// Worker.RunPrune serializes prune against in-flight acquisitions.
|
||||
if err := store.Remove(h, arts[h].Mime, cutoff); err != nil {
|
||||
log.Warn(ctx, "Prune: could not remove artwork file", "hash", h, err)
|
||||
log.Warn(ctx, "Artwork: Could not remove orphan file", "hash", h, err)
|
||||
}
|
||||
removed++
|
||||
}
|
||||
log.Info(ctx, "Prune: removed orphan artwork", "count", removed)
|
||||
log.Info(ctx, "Artwork: Removed orphan images", "count", removed)
|
||||
}
|
||||
|
||||
mimes, err := repo.GetAllMimes()
|
||||
@ -80,7 +80,7 @@ func prune(ctx context.Context, ds model.DataStore, store *ImageStore) error {
|
||||
return err
|
||||
}
|
||||
if removed > 0 {
|
||||
log.Info(ctx, "Prune: swept stray artwork files", "count", removed)
|
||||
log.Info(ctx, "Artwork: Swept stray files", "count", removed)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ func (s *service) serveHash(ctx context.Context, artID model.ArtworkID, ia *mode
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return nil, err
|
||||
}
|
||||
log.Warn(ctx, "artwork: could not serve image", "artID", artID, "size", size, err)
|
||||
log.Warn(ctx, "Artwork: Could not serve image", "artID", artID, "size", size, err)
|
||||
return s.dangling(ctx, artID)
|
||||
}
|
||||
return img, nil
|
||||
@ -336,7 +336,7 @@ func (s *service) enqueue(ctx context.Context, artID model.ArtworkID, priority i
|
||||
Priority: priority,
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn(ctx, "artwork: could not enqueue re-resolution", "artID", artID, err)
|
||||
log.Warn(ctx, "Artwork: Could not enqueue re-resolution", "artID", artID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ func (w *Worker) runPool(ctx context.Context, p *drainPool) {
|
||||
for {
|
||||
n, err := w.drain(ctx, p.concurrency, p.kinds...)
|
||||
if err != nil && ctx.Err() == nil {
|
||||
log.Warn(ctx, "artwork: worker drain failed", "pool", p.name, err)
|
||||
log.Warn(ctx, "Artwork: Worker drain failed", "pool", p.name, err)
|
||||
}
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
@ -147,7 +147,7 @@ func (w *Worker) Bump(kind, id string) {
|
||||
Priority: model.ArtworkPriorityBump,
|
||||
}
|
||||
if err := w.deps.ds.ArtworkQueue(context.Background()).Enqueue(item); err != nil {
|
||||
log.Warn("artwork: could not bump queue item", "kind", kind, "id", id, err)
|
||||
log.Warn("Artwork: Could not bump queue item", "kind", kind, "id", id, err)
|
||||
return
|
||||
}
|
||||
// Waking all beats routing by kind: a spurious wake costs one empty dequeue, while an
|
||||
@ -261,7 +261,7 @@ func (w *Worker) process(ctx context.Context, item model.ArtworkQueueItem) (outc
|
||||
// DeleteIfUnchanged, not Delete: a scan that re-enqueued this row mid-flight reset
|
||||
// its retry_at, so the row survives here and the next drain re-resolves it.
|
||||
if err := queue.DeleteIfUnchanged(item.ItemKind, item.ItemID, item.ImageType, item.RetryAt); err != nil {
|
||||
log.Warn(ctx, "artwork: could not delete processed queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Could not delete processed queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
}
|
||||
case outcomeFoundStale, outcomeFailed:
|
||||
retryAt := time.Now().Add(backoff(item.Attempts))
|
||||
@ -269,7 +269,7 @@ func (w *Worker) process(ctx context.Context, item model.ArtworkQueueItem) (outc
|
||||
// MarkFailedIfUnchanged, not MarkFailed: a scan that re-enqueued this row mid-flight reset
|
||||
// retry_at, so stale backoff must not stomp its fresh, immediate eligibility.
|
||||
if err := queue.MarkFailedIfUnchanged(item.ItemKind, item.ItemID, item.ImageType, item.RetryAt, retryAt); err != nil {
|
||||
log.Warn(ctx, "artwork: could not reschedule failed queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Could not reschedule failed queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -281,7 +281,7 @@ func (w *Worker) process(ctx context.Context, item model.ArtworkQueueItem) (outc
|
||||
writeAbsent(ctx, w.deps.ds.Artwork(ctx), item)
|
||||
}
|
||||
if err := queue.DeleteIfUnchanged(item.ItemKind, item.ItemID, item.ImageType, item.RetryAt); err != nil {
|
||||
log.Warn(ctx, "artwork: could not remove exhausted queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
log.Warn(ctx, "Artwork: Could not remove exhausted queue item", "kind", item.ItemKind, "id", item.ItemID, err)
|
||||
}
|
||||
}
|
||||
return out, got
|
||||
@ -315,7 +315,7 @@ func (w *Worker) precache(ctx context.Context, got *acquired) {
|
||||
}
|
||||
stream, err := w.deps.cache.Get(ctx, item)
|
||||
if err != nil {
|
||||
log.Debug(ctx, "artwork: precache failed", "kind", got.ia.ItemKind, "id", got.ia.ItemID, err)
|
||||
log.Debug(ctx, "Artwork: Precache failed", "kind", got.ia.ItemKind, "id", got.ia.ItemID, err)
|
||||
return
|
||||
}
|
||||
_, _ = io.Copy(io.Discard, stream)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user