From 3c82c4da6312a085adabf8d81763eda20dd47662 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Fri, 28 Apr 2023 17:10:50 -0400 Subject: [PATCH] Refactoring logging a bit mostly busywork, but i'm trying to make myself remember that With() exists for when things start getting more complicated --- attachments.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/attachments.go b/attachments.go index 3e60e5b..6f96bbb 100644 --- a/attachments.go +++ b/attachments.go @@ -59,10 +59,10 @@ func (am *AttachmentMover) findNotes(path string, d fs.DirEntry, err error) erro if d.IsDir() { return nil } - walkLogger := am.L.Named("FindNotes") + walkLogger := am.L.Named("FindNotes").With(zap.String("path", path)) if strings.HasSuffix(path, ".md") && strings.Contains(path, am.BlogDir) { - walkLogger.Info("found blog post to publish, adding to index", zap.String("path", path)) + walkLogger.Info("found blog post to publish, adding to index") am.Notes = append(am.Notes, path) } return nil @@ -76,10 +76,10 @@ func (am *AttachmentMover) findAttachments(path string, d fs.DirEntry, err error if d.IsDir() { return nil } - walkLogger := am.L.Named("FindAttachments") + walkLogger := am.L.Named("FindAttachments").With(zap.String("path", path)) if strings.Contains(path, am.AttachmentsDir) { - walkLogger.Info("found attachment file, adding to index", zap.String("path", path)) + walkLogger.Info("found attachment file, adding to index") am.Attachments[path] = true } return nil @@ -93,10 +93,10 @@ func (am *AttachmentMover) findPosts(path string, d fs.DirEntry, err error) erro if d.IsDir() { return nil } - walkLogger := am.L.Named("FindPosts") + walkLogger := am.L.Named("FindPosts").With(zap.String("path", path)) if strings.HasSuffix(path, "index.md") { - walkLogger.Info("found index.md, adding to index", zap.String("path", path)) + walkLogger.Info("found index.md, adding to index") am.Posts = append(am.Posts, path) } return nil