diff --git a/db.go b/db.go index f2a5740bc..2a4f1d6e0 100644 --- a/db.go +++ b/db.go @@ -3,6 +3,7 @@ package pilosa import ( "errors" "fmt" + "io" "io/ioutil" "os" "path/filepath" @@ -34,6 +35,8 @@ type DB struct { profileAttrStore *AttrStore stats StatsClient + + LogOutput io.Writer } // NewDB returns a new instance of DB. @@ -46,7 +49,8 @@ func NewDB(path, name string) *DB { profileAttrStore: NewAttrStore(filepath.Join(path, "data")), - stats: NopStatsClient, + stats: NopStatsClient, + LogOutput: ioutil.Discard, } } @@ -271,6 +275,7 @@ func (db *DB) createFrameIfNotExists(name string) (*Frame, error) { func (db *DB) newFrame(path, name string) *Frame { f := NewFrame(path, db.name, name) + f.LogOutput = db.LogOutput f.stats = db.stats.WithTags(fmt.Sprintf("frame:%s", name)) return f } diff --git a/db_test.go b/db_test.go index 46a138c87..db017dcd4 100644 --- a/db_test.go +++ b/db_test.go @@ -89,7 +89,6 @@ func NewDB() *DB { if err != nil { panic(err) } - return &DB{DB: pilosa.NewDB(path, "d")} } diff --git a/fragment.go b/fragment.go index 4d0586952..1181f1739 100644 --- a/fragment.go +++ b/fragment.go @@ -97,7 +97,7 @@ func NewFragment(path, db, frame string, slice uint64) *Fragment { frame: frame, slice: slice, - LogOutput: os.Stderr, + LogOutput: ioutil.Discard, MaxOpN: DefaultFragmentMaxOpN, stats: NopStatsClient, @@ -861,7 +861,7 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error { // no real danger if i == 0 || bitmapID != lastID { lastID = bitmapID - set[bitmapID] = struct{}{} + set[bitmapID] = struct{}{} } if changed { bmCounter += 1 diff --git a/frame.go b/frame.go index 0456488a3..9cdb4c707 100644 --- a/frame.go +++ b/frame.go @@ -2,6 +2,7 @@ package pilosa import ( "fmt" + "io" "io/ioutil" "os" "path/filepath" @@ -32,6 +33,8 @@ type Frame struct { bitmapAttrStore *AttrStore stats StatsClient + + LogOutput io.Writer } // NewFrame returns a new instance of frame. @@ -45,6 +48,8 @@ func NewFrame(path, db, name string) *Frame { bitmapAttrStore: NewAttrStore(filepath.Join(path, "data")), stats: NopStatsClient, + + LogOutput: ioutil.Discard, } } @@ -282,6 +287,7 @@ func (f *Frame) createFragmentIfNotExists(slice uint64) (*Fragment, error) { func (f *Frame) newFragment(path string, slice uint64) *Fragment { frag := NewFragment(path, f.db, f.name, slice) + frag.LogOutput = f.LogOutput frag.stats = f.stats.WithTags(fmt.Sprintf("slice:%d", slice)) return frag } diff --git a/handler_test.go b/handler_test.go index 6e998191a..cc86df4b8 100644 --- a/handler_test.go +++ b/handler_test.go @@ -730,6 +730,7 @@ func NewHandler() *Handler { Handler: pilosa.NewHandler(), } h.Handler.Executor = &h.Executor + h.Handler.LogOutput = ioutil.Discard return h } diff --git a/index.go b/index.go index 6b5de11d5..12e3ca9bb 100644 --- a/index.go +++ b/index.go @@ -188,6 +188,7 @@ func (i *Index) createDBIfNotExists(name string) (*DB, error) { func (i *Index) newDB(path, name string) *DB { db := NewDB(path, name) + db.LogOutput = i.LogOutput db.stats = i.Stats.WithTags(fmt.Sprintf("db:%s", db.Name())) return db }