From cd0c82a900f2e9698663e23e95be94c0c940dcf8 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 10 Dec 2024 10:48:45 -0500 Subject: [PATCH] Update compile.go Signed-off-by: Jason Hall --- pkg/compile/compile.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/compile/compile.go b/pkg/compile/compile.go index 2c818cc62..b596878d3 100644 --- a/pkg/compile/compile.go +++ b/pkg/compile/compile.go @@ -113,6 +113,7 @@ var rulesWithWarnings = map[string]bool{ } func Recursive(ctx context.Context, fss []fs.FS) (*yara.Rules, error) { + logger := clog.FromContext(ctx) yc, err := yara.NewCompiler() if err != nil { return nil, fmt.Errorf("yara compiler: %w", err) @@ -159,9 +160,9 @@ func Recursive(ctx context.Context, fss []fs.FS) (*yara.Rules, error) { errors := []string{} for _, yce := range yc.Errors { - clog.ErrorContext(ctx, "error", slog.String("filename", yce.Filename), slog.Int("line", yce.Line), slog.String("text", yce.Text)) + logger.With("line", yce.Line, "filename", yce.Filename).Errorf("error: %s", yce.Text) if yce.Rule != "" { - clog.ErrorContext(ctx, "defective rule", slog.String("rule", yce.Rule)) + logger.With("rule", yce.Rule).Error("defective rule") } errors = append(errors, yce.Text) } @@ -190,9 +191,9 @@ func Recursive(ctx context.Context, fss []fs.FS) (*yara.Rules, error) { continue } if !known { - clog.ErrorContext(ctx, "error", slog.String("namespace", r.Namespace()), slog.String("id", id), slog.String("disabled due to unexpected warning", warnings[id])) + logger.With("namespace, r.Namespace(), "id", id).Errorf("disabled due to unexpected warning: %s", warnings[id]) } else { - clog.InfoContext(ctx, "info", slog.String("namespace", r.Namespace()), slog.String("id", id), slog.String("disabled due to expected warning", warnings[id])) + logger.With("namespace, r.Namespace(), "id", id).Infof("disabled due to unexpected warning: %s", warnings[id]) } r.Disable() }