From 8f5b397cc92c1b90c2a0a8236f6fa245d0e632cc Mon Sep 17 00:00:00 2001 From: Spencer Schrock Date: Tue, 2 Jul 2024 10:48:22 -0700 Subject: [PATCH] add WithLogLevel option Signed-off-by: Spencer Schrock --- pkg/scorecard.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/scorecard.go b/pkg/scorecard.go index bf13c246228..5b949622824 100644 --- a/pkg/scorecard.go +++ b/pkg/scorecard.go @@ -301,14 +301,22 @@ type runConfig struct { ciiClient clients.CIIBestPracticesClient projectClient packageclient.ProjectPackageClient ossfuzzClient clients.RepoClient - checks []string commit string + logLevel sclog.Level + checks []string probes []string commitDepth int } type Option func(*runConfig) error +func WithLogLevel(level sclog.Level) Option { + return func(c *runConfig) error { + c.logLevel = level + return nil + } +} + func WithCommitDepth(depth int) Option { return func(c *runConfig) error { c.commitDepth = depth @@ -366,16 +374,16 @@ func WithOpenSSFBestPraticesClient(client clients.CIIBestPracticesClient) Option } func Run(ctx context.Context, repo clients.Repo, opts ...Option) (ScorecardResult, error) { - // TODO logger - logger := sclog.NewLogger(sclog.InfoLevel) c := runConfig{ - commit: clients.HeadSHA, + commit: clients.HeadSHA, + logLevel: sclog.DefaultLevel, } for _, option := range opts { if err := option(&c); err != nil { return ScorecardResult{}, err } } + logger := sclog.NewLogger(c.logLevel) if c.ciiClient == nil { c.ciiClient = clients.DefaultCIIBestPracticesClient() }