diff options
author | 2023-09-24 16:32:09 -0700 | |
---|---|---|
committer | 2023-09-24 22:37:33 -0700 | |
commit | c0e954f19d707fef8ef8271636ec661634a4c4c7 (patch) | |
tree | 5aa052a048f470e233a454e5ad9071eed1fa37c0 /internal/storage/entry.go | |
parent | 54cb8fa0286e4a2f1a81c32b5a89722d93b30bf7 (diff) | |
download | v2-c0e954f19d707fef8ef8271636ec661634a4c4c7.tar.gz v2-c0e954f19d707fef8ef8271636ec661634a4c4c7.tar.zst v2-c0e954f19d707fef8ef8271636ec661634a4c4c7.zip |
Implement structured logging using log/slog package
Diffstat (limited to 'internal/storage/entry.go')
-rw-r--r-- | internal/storage/entry.go | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/internal/storage/entry.go b/internal/storage/entry.go index 718f50d1..e36646b4 100644 --- a/internal/storage/entry.go +++ b/internal/storage/entry.go @@ -7,10 +7,10 @@ import ( "database/sql" "errors" "fmt" + "log/slog" "time" "miniflux.app/v2/internal/crypto" - "miniflux.app/v2/internal/logger" "miniflux.app/v2/internal/model" "github.com/lib/pq" @@ -52,7 +52,10 @@ func (s *Storage) CountUnreadEntries(userID int64) int { n, err := builder.CountEntries() if err != nil { - logger.Error(`store: unable to count unread entries for user #%d: %v`, userID, err) + slog.Error("Unable to count unread entries", + slog.Int64("user_id", userID), + slog.Any("error", err), + ) return 0 } @@ -316,7 +319,11 @@ func (s *Storage) RefreshFeedEntries(userID, feedID int64, entries model.Entries go func() { if err := s.cleanupEntries(feedID, entryHashes); err != nil { - logger.Error(`store: feed #%d: %v`, feedID, err) + slog.Error("Unable to cleanup entries", + slog.Int64("user_id", userID), + slog.Int64("feed_id", feedID), + slog.Any("error", err), + ) } }() @@ -463,7 +470,10 @@ func (s *Storage) MarkAllAsRead(userID int64) error { } count, _ := result.RowsAffected() - logger.Debug("[Storage:MarkAllAsRead] %d items marked as read", count) + slog.Debug("Marked all entries as read", + slog.Int64("user_id", userID), + slog.Int64("nb_entries", count), + ) return nil } @@ -490,7 +500,10 @@ func (s *Storage) MarkGloballyVisibleFeedsAsRead(userID int64) error { } count, _ := result.RowsAffected() - logger.Debug("[Storage:MarkGloballyVisibleFeedsAsRead] %d items marked as read", count) + slog.Debug("Marked globally visible feed entries as read", + slog.Int64("user_id", userID), + slog.Int64("nb_entries", count), + ) return nil } @@ -512,7 +525,11 @@ func (s *Storage) MarkFeedAsRead(userID, feedID int64, before time.Time) error { } count, _ := result.RowsAffected() - logger.Debug("[Storage:MarkFeedAsRead] %d items marked as read", count) + slog.Debug("Marked feed entries as read", + slog.Int64("user_id", userID), + slog.Int64("feed_id", feedID), + slog.Int64("nb_entries", count), + ) return nil } @@ -540,7 +557,11 @@ func (s *Storage) MarkCategoryAsRead(userID, categoryID int64, before time.Time) } count, _ := result.RowsAffected() - logger.Debug("[Storage:MarkCategoryAsRead] %d items marked as read", count) + slog.Debug("Marked category entries as read", + slog.Int64("user_id", userID), + slog.Int64("category_id", categoryID), + slog.Int64("nb_entries", count), + ) return nil } |