repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
d8efabf
parent
aa393e3
author
Eric Bower
date
2024-10-04 18:10:02 +0000 UTC
chore: logs
2 files changed,  +13, -9
M feeds/cron.go
+7, -8
 1@@ -151,10 +151,10 @@ func (f *Fetcher) RunPost(logger *slog.Logger, user *db.User, post *db.Post) err
 2 
 3 	parsed := shared.ListParseText(post.Text)
 4 
 5-	logger.Info("last digest at", "lastDigest", post.Data.LastDigest)
 6+	logger.Info("last digest at", "lastDigest", post.Data.LastDigest.Format(time.RFC3339))
 7 	err := f.Validate(post, parsed)
 8 	if err != nil {
 9-		logger.Info("validation failed", "err", err.Error())
10+		logger.Info("validation failed", "err", err)
11 		return nil
12 	}
13 
14@@ -209,7 +209,7 @@ func (f *Fetcher) RunUser(user *db.User) error {
15 	for _, post := range posts.Data {
16 		err = f.RunPost(logger, user, post)
17 		if err != nil {
18-			logger.Info("RunPost failed", "err", err.Error())
19+			logger.Error("run post failed", "err", err)
20 		}
21 	}
22 
23@@ -238,7 +238,6 @@ func (f *Fetcher) ParseURL(fp *gofeed.Parser, url string) (*gofeed.Feed, error)
24 	}
25 
26 	feed, err := fp.ParseString(string(body))
27-
28 	if err != nil {
29 		return nil, err
30 	}
31@@ -351,9 +350,9 @@ func (f *Fetcher) FetchAll(logger *slog.Logger, urls []string, inlineContent boo
32 		feedTmpl, err := f.Fetch(logger, fp, url, username, feedItems)
33 		if err != nil {
34 			if errors.Is(err, ErrNoRecentArticles) {
35-				logger.Info("no recent articles", "err", err.Error())
36+				logger.Info("no recent articles", "err", err)
37 			} else {
38-				logger.Error("fetch error", "err", err.Error())
39+				logger.Error("fetch error", "err", err)
40 			}
41 			continue
42 		}
43@@ -447,7 +446,7 @@ func (f *Fetcher) Run(logger *slog.Logger) error {
44 	for _, user := range users {
45 		err := f.RunUser(user)
46 		if err != nil {
47-			logger.Error("RunUser failed", "err", err.Error())
48+			logger.Error("run user failed", "err", err)
49 			continue
50 		}
51 	}
52@@ -462,7 +461,7 @@ func (f *Fetcher) Loop() {
53 
54 		err := f.Run(logger)
55 		if err != nil {
56-			logger.Error(err.Error())
57+			logger.Error("run failed", "err", err)
58 		}
59 
60 		logger.Info("digest emailer finished, waiting 10 mins")
M pgs/api.go
+6, -1
 1@@ -219,7 +219,11 @@ func (h *AssetHandler) handle(logger *slog.Logger, w http.ResponseWriter, r *htt
 2 			// fetch content from url and serve it
 3 			resp, err := http.Get(fp.Filepath)
 4 			if err != nil {
 5-				logger.Error("external service not found", "err", err)
 6+				logger.Error(
 7+					"external service not found",
 8+					"err", err,
 9+					"status", http.StatusNotFound,
10+				)
11 				http.Error(w, "404 not found", http.StatusNotFound)
12 				return
13 			}
14@@ -258,6 +262,7 @@ func (h *AssetHandler) handle(logger *slog.Logger, w http.ResponseWriter, r *htt
15 		logger.Info(
16 			"asset not found in bucket",
17 			"routes", strings.Join(attempts, ", "),
18+			"status", http.StatusNotFound,
19 		)
20 		// track 404s
21 		ch := shared.GetAnalyticsQueue(r)