From b71a40f654557b5729e48739224657b795c4aeed Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 26 Jul 2026 21:11:44 -0400 Subject: [PATCH] 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. --- core/artwork/agent_images.go | 4 ++-- core/artwork/folders_artist.go | 2 +- core/artwork/housekeeping.go | 2 +- core/artwork/processor.go | 18 +++++++++--------- core/artwork/prune.go | 10 +++++----- core/artwork/serving.go | 4 ++-- core/artwork/worker.go | 12 ++++++------ 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/core/artwork/agent_images.go b/core/artwork/agent_images.go index e9dddb7de..dd8c50727 100644 --- a/core/artwork/agent_images.go +++ b/core/artwork/agent_images.go @@ -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 diff --git a/core/artwork/folders_artist.go b/core/artwork/folders_artist.go index b858a0db5..ec80a3fca 100644 --- a/core/artwork/folders_artist.go +++ b/core/artwork/folders_artist.go @@ -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) diff --git a/core/artwork/housekeeping.go b/core/artwork/housekeeping.go index 365438549..33eeea66a 100644 --- a/core/artwork/housekeeping.go +++ b/core/artwork/housekeeping.go @@ -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 } diff --git a/core/artwork/processor.go b/core/artwork/processor.go index 7ce5a44b1..fcdcaa44a 100644 --- a/core/artwork/processor.go +++ b/core/artwork/processor.go @@ -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 = "" } diff --git a/core/artwork/prune.go b/core/artwork/prune.go index 7c3e59676..265eb8262 100644 --- a/core/artwork/prune.go +++ b/core/artwork/prune.go @@ -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 } diff --git a/core/artwork/serving.go b/core/artwork/serving.go index e3fb65eb0..c3eb926d8 100644 --- a/core/artwork/serving.go +++ b/core/artwork/serving.go @@ -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) } } diff --git a/core/artwork/worker.go b/core/artwork/worker.go index dfd5f2de6..0fece4ed3 100644 --- a/core/artwork/worker.go +++ b/core/artwork/worker.go @@ -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)