From f7cd824968414a6741053f3f2a0650b88ebeb7d8 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Fri, 28 Apr 2023 16:14:10 -0400 Subject: [PATCH] Inject logging before starting any work --- main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 6575bb7..5ea0822 100644 --- a/main.go +++ b/main.go @@ -106,24 +106,31 @@ func (am *AttachmentMover) Move() error { moveLogger.Info("scanning posts", zap.Strings("posts", am.Posts)) for _, post := range am.Posts { // log.Printf("scanning %q for attachment links", post) - linkedAttachments, err := extractAttachments(post) + linkedAttachments, err := extractAttachments(post, am.L.Named("extractAttachments")) if err != nil { return fmt.Errorf("could not extract attachment links from %q: %w", post, err) } for _, attachment := range linkedAttachments { - moveAttachment(post, attachment) + moveAttachment(post, attachment, am.L.Named("moveAttachment")) } } return nil } -func moveAttachment(post, attachment string) error { +func moveAttachment(post, attachment string, l *zap.Logger) error { + l.Info("moving attachment", + zap.String("post", post), + zap.String("attachment", attachment), + ) return nil } -func extractAttachments(fn string) ([]string, error) { +func extractAttachments(post string, l *zap.Logger) ([]string, error) { + l.Info("extracting attachment", + zap.String("post", post), + ) attachments := make([]string, 0) return attachments, nil