deps: convert zap to slog (#2825)

This commit is contained in:
miampf 2024-02-08 14:20:01 +00:00 committed by GitHub
parent 3765cb0762
commit 54cce77bab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
182 changed files with 1474 additions and 1509 deletions

View file

@ -8,12 +8,12 @@ package main
import (
"fmt"
"io"
"log/slog"
"os"
"github.com/edgelesssys/constellation/v2/hack/oci-pin/internal/sums"
"github.com/edgelesssys/constellation/v2/internal/logger"
"github.com/spf13/cobra"
"go.uber.org/zap/zapcore"
)
func newMergeCmd() *cobra.Command {
@ -35,10 +35,10 @@ func runMerge(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
log := logger.New(logger.PlainLog, flags.logLevel)
log.Debugf("Parsed flags: %+v", flags)
log := logger.NewTextLogger(flags.logLevel)
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
log.Debugf("Merging sum file from %q into %q.", flags.inputs, flags.output)
log.Debug(fmt.Sprintf("Merging sum file from %q into %q.", flags.inputs, flags.output))
var out io.Writer
if flags.output == "-" {
@ -61,7 +61,7 @@ func runMerge(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("creating merged sum file: %w", err)
}
log.Debugf("Sum file created at %q 🤖", flags.output)
log.Debug(fmt.Sprintf("Sum file created at %q 🤖", flags.output))
return nil
}
@ -93,7 +93,7 @@ func parseInput(input string) ([]sums.PinnedImageReference, error) {
type mergeFlags struct {
inputs []string
output string
logLevel zapcore.Level
logLevel slog.Level
}
func parseMergeFlags(cmd *cobra.Command) (mergeFlags, error) {
@ -109,9 +109,9 @@ func parseMergeFlags(cmd *cobra.Command) (mergeFlags, error) {
if err != nil {
return mergeFlags{}, err
}
logLevel := zapcore.InfoLevel
logLevel := slog.LevelInfo
if verbose {
logLevel = zapcore.DebugLevel
logLevel = slog.LevelDebug
}
return mergeFlags{