Skip to content

Commit

Permalink
pass logrus logger to badger
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstruck committed Sep 24, 2019
1 parent d0440f1 commit 02c2fb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/kvload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var Cmd = &cobra.Command{
return err
}
db := kvgraph.NewKVGraph(kv)
defer db.Close()

_ = db.AddGraph(graph)
kgraph, err := db.Graph(graph)
Expand Down Expand Up @@ -83,7 +84,7 @@ var Cmd = &cobra.Command{
go func() {
wg.Add(1)
if err := kgraph.BulkAdd(graphChan); err != nil {
log.Error(err)
log.Errorf("BulkdAdd: %v", err)
}
wg.Done()
}()
Expand All @@ -100,6 +101,7 @@ var Cmd = &cobra.Command{
log.Infof("Loaded %d vertices (%d/sec)", count, vertexCounter.Rate()/10)
}
}
log.Infof("Loaded %d vertices (%d/sec)", count, vertexCounter.Rate()/10)
}

edgeCounter := ratecounter.NewRateCounter(10 * time.Second)
Expand All @@ -114,10 +116,11 @@ var Cmd = &cobra.Command{
log.Infof("Loaded %d edges (%d/sec)", count, edgeCounter.Rate()/10)
}
}
log.Infof("Loaded %d edges (%d/sec)", count, edgeCounter.Rate()/10)
}

close(graphChan)
wg.Wait()
db.Close()
return nil
},
}
Expand Down
4 changes: 4 additions & 0 deletions kvi/badgerdb/badger_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ func NewKVInterface(path string, kopts kvi.Options) (kvi.KVInterface, error) {
}
}

blog := log.New()
blog.SetLevel(log.WarnLevel)

opts := badger.Options{}
opts = badger.DefaultOptions(path)
opts.TableLoadingMode = options.MemoryMap
opts.Dir = path
opts.ValueDir = path
opts.Logger = blog
db, err := badger.Open(opts)
if err != nil {
return nil, err
Expand Down

0 comments on commit 02c2fb7

Please sign in to comment.