Move "Molecula Consumer" message to the logger; hide it in basic mode

This commit is contained in:
Travis Turner 2023-02-27 22:56:34 -06:00
parent 7a7bb0c928
commit 634553d3c3
No known key found for this signature in database
GPG key ID: 3FB5CF5C97A37B30
3 changed files with 9 additions and 3 deletions

View file

@ -384,6 +384,7 @@ func (cmd *Command) setupConfig() error {
cmd.kafkaRunner = kafka.NewRunner(
cleanCfg,
batch.NewSQLBatcher(cmd, kafka.ConfigToFields(cfg)),
cmd.Stderr,
)
}

View file

@ -1,12 +1,14 @@
package kafka
import (
"io"
"time"
fbbatch "github.com/featurebasedb/featurebase/v3/batch"
"github.com/featurebasedb/featurebase/v3/errors"
"github.com/featurebasedb/featurebase/v3/idk"
"github.com/featurebasedb/featurebase/v3/idk/kafka_static"
"github.com/featurebasedb/featurebase/v3/logger"
)
type Runner struct {
@ -18,7 +20,7 @@ type Runner struct {
Header []idk.RawField `help:"Header configuration."`
}
func NewRunner(cfg ConfigForIDK, batcher fbbatch.Batcher) *Runner {
func NewRunner(cfg ConfigForIDK, batcher fbbatch.Batcher, logWriter io.Writer) *Runner {
idkMain := idk.NewMain()
idkMain.IDField = cfg.IDField
idkMain.Index = cfg.Table
@ -26,6 +28,7 @@ func NewRunner(cfg ConfigForIDK, batcher fbbatch.Batcher) *Runner {
idkMain.BatchSize = cfg.BatchSize
idkMain.BatchMaxStaleness = cfg.BatchMaxStaleness
idkMain.Basic()
idkMain.SetLog(logger.NewStandardLogger(logWriter))
kr := &Runner{
Main: *idkMain,

View file

@ -216,8 +216,6 @@ func (m *Main) Log() logger.Logger { return m.log }
func (m *Main) SetLog(log logger.Logger) { m.log = log }
func NewMain() *Main {
fmt.Fprintf(os.Stderr, "Molecula Consumer %s, build time %s\n", Version, BuildTime)
return &Main{
PilosaHosts: []string{"localhost:10101"},
PilosaGRPCHosts: []string{"localhost:20101"},
@ -254,6 +252,10 @@ func (m *Main) Basic() {
}
func (m *Main) Run() (err error) {
if !m.basic {
m.log.Printf("Molecula Consumer %s, build time %s\n", Version, BuildTime)
}
onFinishRun, err := m.Setup()
if err != nil {
return errors.Wrap(err, "setting up")