1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Implement structured logging using log/slog package

This commit is contained in:
Frédéric Guillot 2023-09-24 16:32:09 -07:00
parent 54cb8fa028
commit c0e954f19d
77 changed files with 1868 additions and 892 deletions

View file

@ -238,7 +238,7 @@ func (s *Storage) RemoveCategory(userID, categoryID int64) error {
func (s *Storage) RemoveAndReplaceCategoriesByName(userid int64, titles []string) error {
tx, err := s.db.Begin()
if err != nil {
return errors.New("unable to begin transaction")
return errors.New("store: unable to begin transaction")
}
titleParam := pq.Array(titles)
@ -247,11 +247,11 @@ func (s *Storage) RemoveAndReplaceCategoriesByName(userid int64, titles []string
err = tx.QueryRow(query, userid, titleParam).Scan(&count)
if err != nil {
tx.Rollback()
return errors.New("unable to retrieve category count")
return errors.New("store: unable to retrieve category count")
}
if count < 1 {
tx.Rollback()
return errors.New("at least 1 category must remain after deletion")
return errors.New("store: at least 1 category must remain after deletion")
}
query = `
@ -268,14 +268,14 @@ func (s *Storage) RemoveAndReplaceCategoriesByName(userid int64, titles []string
_, err = tx.Exec(query, userid, titleParam)
if err != nil {
tx.Rollback()
return fmt.Errorf("unable to replace categories: %v", err)
return fmt.Errorf("store: unable to replace categories: %v", err)
}
query = "DELETE FROM categories WHERE user_id = $1 AND title = ANY($2)"
_, err = tx.Exec(query, userid, titleParam)
if err != nil {
tx.Rollback()
return fmt.Errorf("unable to delete categories: %v", err)
return fmt.Errorf("store: unable to delete categories: %v", err)
}
tx.Commit()
return nil