Skip to content

Commit 0198433

Browse files
authored
fix logger error message output (#882)
* replace w with v in logger message Signed-off-by: pxp928 <[email protected]> * change between error message and logger Signed-off-by: pxp928 <[email protected]> --------- Signed-off-by: pxp928 <[email protected]>
1 parent b696c10 commit 0198433

File tree

18 files changed

+52
-58
lines changed

18 files changed

+52
-58
lines changed

cmd/guacingest/cmd/ingest.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func ingest(cmd *cobra.Command, args []string) {
6767
jetStream := emitter.NewJetStream(opts.natsAddr, "", "")
6868
ctx, err = jetStream.JetStreamInit(ctx)
6969
if err != nil {
70-
logger.Errorf("jetStream initialization failed with error: %w", err)
70+
logger.Errorf("jetStream initialization failed with error: %v", err)
7171
os.Exit(1)
7272
}
7373
defer jetStream.Close()
7474

7575
// initialize collectsub client
7676
csubClient, err := csub_client.NewClient(opts.csubAddr)
7777
if err != nil {
78-
logger.Errorf("collectsub client initialization failed with error: %w", err)
78+
logger.Errorf("collectsub client initialization failed with error: %v", err)
7979
os.Exit(1)
8080
}
8181
defer csubClient.Close()
@@ -116,13 +116,13 @@ func ingest(cmd *cobra.Command, args []string) {
116116

117117
processorFunc, err := getProcessor(ctx, processorTransportFunc)
118118
if err != nil {
119-
logger.Errorf("error: %w", err)
119+
logger.Errorf("error: %v", err)
120120
os.Exit(1)
121121
}
122122

123123
ingestorFunc, err := getIngestor(ctx, ingestorTransportFunc)
124124
if err != nil {
125-
logger.Errorf("error: %w", err)
125+
logger.Errorf("error: %v", err)
126126
os.Exit(1)
127127
}
128128

cmd/guacone/cmd/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ var filesCmd = &cobra.Command{
114114
// initialize collectsub client
115115
csubClient, err := csub_client.NewClient(opts.csubAddr)
116116
if err != nil {
117-
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %w", err)
117+
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %v", err)
118118
csubClient = nil
119119
} else {
120120
defer csubClient.Close()

cmd/guacone/cmd/oci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var ociCmd = &cobra.Command{
6767
// initialize collectsub client
6868
csubClient, err := csub_client.NewClient(opts.csubAddr)
6969
if err != nil {
70-
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %w", err)
70+
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %v", err)
7171
csubClient = nil
7272
} else {
7373
defer csubClient.Close()

cmd/guacone/cmd/osv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ var osvCmd = &cobra.Command{
6565
}
6666

6767
if err := certify.RegisterCertifier(osv.NewOSVCertificationParser, certifier.CertifierOSV); err != nil {
68-
logger.Fatalf("unable to register certifier: %w", err)
68+
logger.Fatalf("unable to register certifier: %v", err)
6969
}
7070

7171
// initialize collectsub client
7272
csubClient, err := csub_client.NewClient(opts.csubAddr)
7373
if err != nil {
74-
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %w", err)
74+
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %v", err)
7575
csubClient = nil
7676
} else {
7777
defer csubClient.Close()

cmd/guacone/cmd/scorecard.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var scorecardCmd = &cobra.Command{
7777
// initialize collectsub client
7878
csubClient, err := csub_client.NewClient(opts.csubAddr)
7979
if err != nil {
80-
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %w", err)
80+
logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %v", err)
8181
csubClient = nil
8282
} else {
8383
defer csubClient.Close()
@@ -109,7 +109,7 @@ var scorecardCmd = &cobra.Command{
109109
scCertifier := func() certifier.Certifier { return scorecardCertifier }
110110

111111
if err := certify.RegisterCertifier(scCertifier, certifier.CertifierScorecard); err != nil {
112-
logger.Fatalf("unable to register certifier: %w", err)
112+
logger.Fatalf("unable to register certifier: %v", err)
113113
}
114114
processorFunc := getProcessor(ctx)
115115
collectSubEmitFunc := getCollectSubEmit(ctx, csubClient)

internal/testing/cmd/pubsub_test/cmd/osv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var osvCmd = &cobra.Command{
6262
}
6363

6464
if err := certify.RegisterCertifier(osv.NewOSVCertificationParser, certifier.CertifierOSV); err != nil {
65-
logger.Fatalf("unable to register certifier: %w", err)
65+
logger.Fatalf("unable to register certifier: %v", err)
6666
}
6767

6868
// TODO: Fix this with the graphQL endpoint

pkg/certifier/certify/certify.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func Certify(ctx context.Context, query certifier.QueryComponents, emitter certi
8686
for len(compChan) > 0 {
8787
d := <-compChan
8888
if err := generateDocuments(ctx, d, emitter, handleErr); err != nil {
89-
logger.Errorf("generate certifier documents error: %w", err)
89+
logger.Errorf("generate certifier documents error: %v", err)
9090
}
9191
}
9292
return nil
@@ -140,7 +140,7 @@ func generateDocuments(ctx context.Context, collectedComponent interface{}, emit
140140
select {
141141
case d := <-docChan:
142142
if err := emitter(d); err != nil {
143-
logger.Errorf("emit error: %w", err)
143+
logger.Errorf("emit error: %v", err)
144144
}
145145
case err := <-errChan:
146146
if !handleErr(err) {
@@ -154,7 +154,7 @@ func generateDocuments(ctx context.Context, collectedComponent interface{}, emit
154154
for len(docChan) > 0 {
155155
d := <-docChan
156156
if err := emitter(d); err != nil {
157-
logger.Errorf("emit error: %w", err)
157+
logger.Errorf("emit error: %v", err)
158158
}
159159
}
160160
return nil

pkg/certifier/certify/certify_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ func testSubscribe(ctx context.Context, transportFunc func(processor.DocumentTre
279279
doc := processor.Document{}
280280
err := json.Unmarshal(d, &doc)
281281
if err != nil {
282-
fmtErr := fmt.Errorf("[processor: %s] failed unmarshal the document bytes: %w", uuidString, err)
283-
logger.Error(fmtErr)
284-
return fmtErr
282+
fmtErrString := fmt.Sprintf("[processor: %s] failed unmarshal the document bytes", uuidString)
283+
logger.Errorf(fmtErrString+": %v", err)
284+
return fmt.Errorf(fmtErrString+": %w", err)
285285
}
286286

287287
docNode := &processor.DocumentNode{
@@ -292,9 +292,9 @@ func testSubscribe(ctx context.Context, transportFunc func(processor.DocumentTre
292292
docTree := processor.DocumentTree(docNode)
293293
err = transportFunc(docTree)
294294
if err != nil {
295-
fmtErr := fmt.Errorf("[processor: %s] failed transportFunc: %w", uuidString, err)
296-
logger.Error(fmtErr)
297-
return fmtErr
295+
fmtErrString := fmt.Sprintf("[processor: %s] failed transportFunc", uuidString)
296+
logger.Errorf(fmtErrString+": %v", err)
297+
return fmt.Errorf(fmtErrString+": %w", err)
298298
}
299299
logger.Infof("[processor: %s] docTree Processed: %+v", uuidString, docTree.Document.SourceInformation)
300300
return nil

pkg/emitter/nats_emitter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func createSubscriber(ctx context.Context, id string, subj string, durable strin
178178
js := FromContext(ctx)
179179
sub, err := js.PullSubscribe(subj, durable)
180180
if err != nil {
181-
logger.Errorf("%s subscribe failed: %w", durable, err)
181+
logger.Errorf("%s subscribe failed: %v", durable, err)
182182
return nil, nil, err
183183
}
184184
go func() {
@@ -207,9 +207,9 @@ func createSubscriber(ctx context.Context, id string, subj string, durable strin
207207
if len(msgs) > 0 {
208208
err := msgs[0].Ack()
209209
if err != nil {
210-
fmtErr := fmt.Errorf("[%s: %v] unable to Ack: %w", durable, id, err)
211-
logger.Error(fmtErr)
212-
errChan <- fmtErr
210+
fmtErrString := fmt.Sprintf("[%s: %v] unable to Ack", durable, id)
211+
logger.Errorf(fmtErrString+": %v", err)
212+
errChan <- fmt.Errorf(fmtErrString+": %w", err)
213213
return
214214
}
215215
dataChan <- msgs[0].Data

pkg/emitter/nats_emitter_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ func testSubscribe(ctx context.Context, transportFunc func(processor.DocumentTre
275275
doc := processor.Document{}
276276
err := json.Unmarshal(d, &doc)
277277
if err != nil {
278-
fmtErr := fmt.Errorf("[processor: %s] failed unmarshal the document bytes: %w", uuidString, err)
279-
logger.Error(fmtErr)
280-
return fmtErr
278+
fmtErrString := fmt.Sprintf("[processor: %s] failed unmarshal the document bytes", uuidString)
279+
logger.Errorf(fmtErrString+": %v", err)
280+
return fmt.Errorf(fmtErrString+": %w", err)
281281
}
282282

283283
docNode := &processor.DocumentNode{
@@ -288,9 +288,9 @@ func testSubscribe(ctx context.Context, transportFunc func(processor.DocumentTre
288288
docTree := processor.DocumentTree(docNode)
289289
err = transportFunc(docTree)
290290
if err != nil {
291-
fmtErr := fmt.Errorf("[processor: %s] failed transportFunc: %w", uuidString, err)
292-
logger.Error(fmtErr)
293-
return fmtErr
291+
fmtErrString := fmt.Sprintf("[processor: %s] failed transportFunc", uuidString)
292+
logger.Errorf(fmtErrString+": %v", err)
293+
return fmt.Errorf(fmtErrString+": %w", err)
294294
}
295295
logger.Infof("[processor: %s] docTree Processed: %+v", uuidString, docTree.Document.SourceInformation)
296296
return nil

0 commit comments

Comments
 (0)