Skip to content

Commit

Permalink
Use logrus, because slog.Error does not log an error from within the …
Browse files Browse the repository at this point in the history
…Kubernetes Pod
  • Loading branch information
domust committed Dec 4, 2024
1 parent cb18d6e commit 8addfcc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/imagescan/imgscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"log/slog"
"net/http"
"net/http/pprof"
"os"
Expand All @@ -20,22 +19,23 @@ import (
)

func NewCommand(version string) *cobra.Command {
// TODO: Switch to pkg/logging.
log := logrus.New()
log.SetLevel(logrus.DebugLevel)

return &cobra.Command{
Use: "scan",
Short: "Run kvisor image scanning",
Run: func(cmd *cobra.Command, args []string) {
if err := run(cmd.Context(), version); err != nil {
slog.Error(err.Error())
if err := run(cmd.Context(), log, version); err != nil {
log.Error(err.Error())
os.Exit(1)
}
},
}
}

func run(ctx context.Context, version string) error {
// TODO: Switch to pkg/logging.
log := logrus.New()
log.SetLevel(logrus.DebugLevel)
func run(ctx context.Context, log *logrus.Logger, version string) error {
log.Infof("running image scan job, version=%s", version)

cfg, err := config.FromEnv()
Expand Down

0 comments on commit 8addfcc

Please sign in to comment.