diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-12-15 18:55:57 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-12-15 18:55:57 -0800 |
commit | 1d8193b892bf63db6b91c66b9d048873bf1bc4cf (patch) | |
tree | 4ca54691f7fab88f73f657f005e26d75ae5f0058 /storage | |
parent | c6d9eb361454b70406cf6573b284d5e99ba3a2d2 (diff) |
Add logger
Diffstat (limited to 'storage')
-rw-r--r-- | storage/entry.go | 4 | ||||
-rw-r--r-- | storage/integration.go | 4 | ||||
-rw-r--r-- | storage/migration.go | 12 | ||||
-rw-r--r-- | storage/storage.go | 4 | ||||
-rw-r--r-- | storage/user.go | 3 |
5 files changed, 13 insertions, 14 deletions
diff --git a/storage/entry.go b/storage/entry.go index a75d41c..6d67397 100644 --- a/storage/entry.go +++ b/storage/entry.go @@ -7,10 +7,10 @@ package storage import ( "errors" "fmt" - "log" "time" "github.com/miniflux/miniflux/helper" + "github.com/miniflux/miniflux/logger" "github.com/miniflux/miniflux/model" "github.com/lib/pq" @@ -137,7 +137,7 @@ func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries) (er } if err := s.CleanupEntries(feedID, entryHashes); err != nil { - log.Println(err) + logger.Error("[Storage:CleanupEntries] %v", err) } return nil diff --git a/storage/integration.go b/storage/integration.go index 886e02f..6d89a68 100644 --- a/storage/integration.go +++ b/storage/integration.go @@ -68,9 +68,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) { ) switch { case err == sql.ErrNoRows: - return nil, nil + return &integration, nil case err != nil: - return nil, fmt.Errorf("unable to fetch integration row: %v", err) + return &integration, fmt.Errorf("unable to fetch integration row: %v", err) } return &integration, nil diff --git a/storage/migration.go b/storage/migration.go index c7d9851..04ffce3 100644 --- a/storage/migration.go +++ b/storage/migration.go @@ -6,9 +6,9 @@ package storage import ( "fmt" - "log" "strconv" + "github.com/miniflux/miniflux/logger" "github.com/miniflux/miniflux/sql" ) @@ -27,7 +27,7 @@ func (s *Storage) Migrate() { tx, err := s.db.Begin() if err != nil { - log.Fatalln(err) + logger.Fatal("[Storage:Migrate] %v", err) } rawSQL := sql.SqlMap["schema_version_"+strconv.Itoa(version)] @@ -35,21 +35,21 @@ func (s *Storage) Migrate() { _, err = tx.Exec(rawSQL) if err != nil { tx.Rollback() - log.Fatalln(err) + logger.Fatal("[Storage:Migrate] %v", err) } if _, err := tx.Exec(`delete from schema_version`); err != nil { tx.Rollback() - log.Fatalln(err) + logger.Fatal("[Storage:Migrate] %v", err) } if _, err := tx.Exec(`insert into schema_version (version) values($1)`, version); err != nil { tx.Rollback() - log.Fatalln(err) + logger.Fatal("[Storage:Migrate] %v", err) } if err := tx.Commit(); err != nil { - log.Fatalln(err) + logger.Fatal("[Storage:Migrate] %v", err) } } } diff --git a/storage/storage.go b/storage/storage.go index c815a06..f7a06b4 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -6,10 +6,10 @@ package storage import ( "database/sql" - "log" // Postgresql driver import _ "github.com/lib/pq" + "github.com/miniflux/miniflux/logger" ) // Storage handles all operations related to the database. @@ -26,7 +26,7 @@ func (s *Storage) Close() { func NewStorage(databaseURL string, maxOpenConns int) *Storage { db, err := sql.Open("postgres", databaseURL) if err != nil { - log.Fatalf("Unable to connect to the database: %v", err) + logger.Fatal("[Storage] Unable to connect to the database: %v", err) } db.SetMaxOpenConns(maxOpenConns) diff --git a/storage/user.go b/storage/user.go index 5fe04cd..d1275cc 100644 --- a/storage/user.go +++ b/storage/user.go @@ -8,7 +8,6 @@ import ( "database/sql" "errors" "fmt" - "log" "strings" "time" @@ -113,7 +112,7 @@ func (s *Storage) RemoveExtraField(userID int64, field string) error { // UpdateUser updates a user. func (s *Storage) UpdateUser(user *model.User) error { defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateUser] userID=%d", user.ID)) - log.Println(user.EntryDirection) + if user.Password != "" { hashedPassword, err := hashPassword(user.Password) if err != nil { |