diff --git a/api/v1/server/handlers/monitoring/probe.go b/api/v1/server/handlers/monitoring/probe.go index ec33adaf5..7352e189d 100644 --- a/api/v1/server/handlers/monitoring/probe.go +++ b/api/v1/server/handlers/monitoring/probe.go @@ -125,19 +125,15 @@ type stepOneOutput struct { func (m *MonitoringService) run(ctx context.Context, cf clientconfig.ClientConfigFile, workflowName string, events chan<- string, stepChan chan<- string, errors chan<- error) (func(), error) { - c, err := client.NewFromConfigFile( - &cf, client.WithLogLevel(m.l.GetLevel().String()), - ) + c, err := client.NewFromConfigFile(&cf, client.WithLogger(m.l)) if err != nil { return nil, fmt.Errorf("error creating client: %w", err) } w, err := worker.NewWorker( - - worker.WithClient( - c, - ), worker.WithLogLevel(m.l.GetLevel().String()), + worker.WithClient(c), + worker.WithLogger(m.l), ) if err != nil { return nil, fmt.Errorf("error creating worker: %w", err) diff --git a/examples/loadtest/cli/run.go b/examples/loadtest/cli/run.go index d86fcfc18..bf913b0e7 100644 --- a/examples/loadtest/cli/run.go +++ b/examples/loadtest/cli/run.go @@ -19,22 +19,12 @@ func getConcurrencyKey(ctx worker.HatchetContext) (string, error) { } func run(ctx context.Context, delay time.Duration, executions chan<- time.Duration, concurrency int) (int64, int64) { - c, err := client.New( - client.WithLogLevel("warn"), - ) - + c, err := client.New() if err != nil { panic(err) } - w, err := worker.NewWorker( - worker.WithClient( - c, - ), - worker.WithLogLevel("warn"), - worker.WithMaxRuns(200), - ) - + w, err := worker.NewWorker(worker.WithClient(c), worker.WithMaxRuns(200)) if err != nil { panic(err) } diff --git a/examples/loadtest/rampup/run.go b/examples/loadtest/rampup/run.go index f13b24a9e..c5eee80e3 100644 --- a/examples/loadtest/rampup/run.go +++ b/examples/loadtest/rampup/run.go @@ -19,22 +19,12 @@ func getConcurrencyKey(ctx worker.HatchetContext) (string, error) { } func run(ctx context.Context, delay time.Duration, concurrency int, maxAcceptableDuration time.Duration, hook chan<- time.Duration, executedCh chan<- int64) (int64, int64) { - c, err := client.New( - client.WithLogLevel("warn"), - ) - + c, err := client.New() if err != nil { panic(err) } - w, err := worker.NewWorker( - worker.WithClient( - c, - ), - worker.WithLogLevel("warn"), - worker.WithMaxRuns(200), - ) - + w, err := worker.NewWorker(worker.WithClient(c), worker.WithMaxRuns(200)) if err != nil { panic(err) } diff --git a/pkg/client/client.go b/pkg/client/client.go index 866dde6e8..aebc90c89 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -135,16 +135,9 @@ func defaultClientOpts(token *string, cf *client.ClientConfigFile) *ClientOpts { } } -func WithLogLevel(lvl string) ClientOpt { +func WithLogger(l *zerolog.Logger) ClientOpt { return func(opts *ClientOpts) { - logger := logger.NewDefaultLogger("client") - lvl, err := zerolog.ParseLevel(lvl) - - if err == nil { - logger = logger.Level(lvl) - } - - opts.l = &logger + opts.l = l } } diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go index 70cb838be..3ddfc5514 100644 --- a/pkg/worker/worker.go +++ b/pkg/worker/worker.go @@ -133,16 +133,11 @@ func defaultWorkerOpts() *WorkerOpts { } } -func WithLogLevel(lvl string) WorkerOpt { +func WithLogger(l *zerolog.Logger) WorkerOpt { return func(opts *WorkerOpts) { - logger := logger.NewDefaultLogger("worker") - lvl, err := zerolog.ParseLevel(lvl) - - if err == nil { - logger = logger.Level(lvl) + if l != nil { + opts.l = l } - - opts.l = &logger } }