refactor: replace zap with slog (#6466)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: Nikita Pivkin <nikita.pivkin@smartforce.io>
Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
This commit is contained in:
Teppei Fukuda
2024-04-11 22:59:09 +04:00
committed by GitHub
parent 336c47ecc3
commit 94d6e8ced6
164 changed files with 1664 additions and 891 deletions

View File

@@ -114,7 +114,7 @@ func loadPluginCommands() []*cobra.Command {
var commands []*cobra.Command
plugins, err := plugin.LoadAll()
if err != nil {
log.Logger.Debugf("no plugins were loaded")
log.Debug("No plugins loaded")
return nil
}
for _, p := range plugins {
@@ -142,12 +142,12 @@ func initConfig(configFile string) error {
viper.SetConfigType("yaml")
if err := viper.ReadInConfig(); err != nil {
if errors.Is(err, os.ErrNotExist) {
log.Logger.Debugf("config file %q not found", configFile)
log.Debug("Config file not found", log.String("file_path", configFile))
return nil
}
return xerrors.Errorf("config file %q loading error: %s", configFile, err)
}
log.Logger.Infof("Loaded %s", configFile)
log.Info("Loaded", log.String("file_path", configFile))
return nil
}
@@ -196,9 +196,7 @@ func NewRootCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command {
}
// Initialize logger
if err := log.InitLogger(globalOptions.Debug, globalOptions.Quiet); err != nil {
return err
}
log.InitLogger(globalOptions.Debug, globalOptions.Quiet)
return nil
},
@@ -570,7 +568,7 @@ func NewClientCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command {
return validateArgs(cmd, args)
},
RunE: func(cmd *cobra.Command, args []string) error {
log.Logger.Warn("'client' subcommand is deprecated now. See https://github.com/aquasecurity/trivy/discussions/2119")
log.Warn("'client' subcommand is deprecated now. See https://github.com/aquasecurity/trivy/discussions/2119")
if err := clientFlags.Bind(cmd); err != nil {
return xerrors.Errorf("flag bind error: %w", err)
@@ -1040,7 +1038,7 @@ The following services are supported:
}
if opts.Timeout < time.Hour {
opts.Timeout = time.Hour
log.Logger.Debug("Timeout is set to less than 1 hour - upgrading to 1 hour for this command.")
log.Info("Timeout is set to less than 1 hour - upgrading to 1 hour for this command.")
}
return awscommands.Run(cmd.Context(), opts)
},
@@ -1106,7 +1104,7 @@ func NewVMCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command {
}
if options.Timeout < time.Minute*30 {
options.Timeout = time.Minute * 30
log.Logger.Debug("Timeout is set to less than 30 min - upgrading to 30 min for this command.")
log.Info("Timeout is set to less than 30 min - upgrading to 30 min for this command.")
}
return artifact.Run(cmd.Context(), options, artifact.TargetVM)
},