improved logging

This commit is contained in:
ston1th 2022-09-19 22:52:40 +02:00
commit 05b41cedce
81 changed files with 9802 additions and 279 deletions

View file

@ -3,11 +3,13 @@
package db
import (
"io"
"path/filepath"
"git.giftfish.de/ston1th/docstore/pkg/core"
"git.giftfish.de/ston1th/docstore/pkg/index"
"git.giftfish.de/ston1th/docstore/pkg/store"
"io"
"path/filepath"
"github.com/go-logr/logr"
)
const (
@ -18,14 +20,15 @@ const (
const blevePath = "bleve"
type DB struct {
log logr.Logger
rm countMutex
IndexMutex countMutex
store store.Store
Index *index.Index
}
func New(cfg *core.Config) (db *DB, err error) {
db, err = NewPlain(cfg)
func New(log logr.Logger, cfg *core.Config) (db *DB, err error) {
db, err = NewPlain(log, cfg)
if err != nil {
return
}
@ -48,8 +51,8 @@ func New(cfg *core.Config) (db *DB, err error) {
return
}
func NewPlain(cfg *core.Config) (db *DB, err error) {
db = new(DB)
func NewPlain(log logr.Logger, cfg *core.Config) (db *DB, err error) {
db = &DB{log: log}
dbFile := filepath.Join(cfg.RunDir, storeFile)
db.store, err = store.NewBoltStore(dbFile, nil)
return