Skip to content

Commit

Permalink
chore: Remove dead logging code
Browse files Browse the repository at this point in the history
Setting the badger logger option after already setting the level
overwrites the changed level, so this commit just removes the unused
option. We will inherit the level of the logrus standard logger anyway.
  • Loading branch information
jameshoulahan authored and LBeernaertProton committed Aug 12, 2022
1 parent 0160bfa commit a2b75a1
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions store/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,12 @@ type BadgerStore struct {
wg sync.WaitGroup
}

func logrusLevelToBadgerLevel(options badger.Options) badger.Options {
switch logrus.GetLevel() {
case logrus.InfoLevel:
return options.WithLoggingLevel(badger.INFO)
case logrus.TraceLevel:
fallthrough
case logrus.DebugLevel:
return options.WithLoggingLevel(badger.DEBUG)
case logrus.WarnLevel:
return options.WithLoggingLevel(badger.WARNING)
case logrus.FatalLevel:
fallthrough
case logrus.PanicLevel:
fallthrough
case logrus.ErrorLevel:
return options.WithLoggingLevel(badger.ERROR)
default:
return options.WithLoggingLevel(badger.ERROR)
}
}

func NewBadgerStore(path string, userID string, encryptionPassphrase []byte) (*BadgerStore, error) {
directory := filepath.Join(path, userID)
db, err := badger.Open(logrusLevelToBadgerLevel(badger.DefaultOptions(directory)).
db, err := badger.Open(badger.DefaultOptions(filepath.Join(path, userID)).
WithLogger(logrus.StandardLogger()).
WithEncryptionKey(encryptionPassphrase).
WithIndexCacheSize(128 * 1024 * 1024))

WithIndexCacheSize(128 * 1024 * 1024),
)
if err != nil {
return nil, nil
}
Expand Down

0 comments on commit a2b75a1

Please sign in to comment.