Inject logging before starting any work

main
Nick Dumas 2 years ago
parent f9cbca8f74
commit f7cd824968

@ -106,24 +106,31 @@ func (am *AttachmentMover) Move() error {
moveLogger.Info("scanning posts", zap.Strings("posts", am.Posts)) moveLogger.Info("scanning posts", zap.Strings("posts", am.Posts))
for _, post := range am.Posts { for _, post := range am.Posts {
// log.Printf("scanning %q for attachment links", post) // log.Printf("scanning %q for attachment links", post)
linkedAttachments, err := extractAttachments(post) linkedAttachments, err := extractAttachments(post, am.L.Named("extractAttachments"))
if err != nil { if err != nil {
return fmt.Errorf("could not extract attachment links from %q: %w", post, err) return fmt.Errorf("could not extract attachment links from %q: %w", post, err)
} }
for _, attachment := range linkedAttachments { for _, attachment := range linkedAttachments {
moveAttachment(post, attachment) moveAttachment(post, attachment, am.L.Named("moveAttachment"))
} }
} }
return nil 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 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) attachments := make([]string, 0)
return attachments, nil return attachments, nil

Loading…
Cancel
Save