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,7 +8,9 @@ package main
import (
"flag"
"log/slog"
"net"
"os"
"strconv"
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
@ -16,7 +18,6 @@ import (
"github.com/edgelesssys/constellation/v2/internal/constants"
"github.com/edgelesssys/constellation/v2/internal/logger"
"github.com/edgelesssys/constellation/v2/verify/server"
"go.uber.org/zap"
)
func main() {
@ -24,33 +25,38 @@ func main() {
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
flag.Parse()
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity))
log := logger.NewJSONLogger(logger.VerbosityFromInt(*verbosity))
log.With(zap.String("version", constants.BinaryVersion().String()), zap.String("attestationVariant", *attestationVariant)).
Infof("Constellation Verification Service")
log.With(slog.String("version", constants.BinaryVersion().String()), slog.String("attestationVariant", *attestationVariant)).
Info("Constellation Verification Service")
variant, err := variant.FromString(*attestationVariant)
if err != nil {
log.With(zap.Error(err)).Fatalf("Failed to parse attestation variant")
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
os.Exit(1)
}
issuer, err := choose.Issuer(variant, log.Named("issuer"))
issuer, err := choose.Issuer(variant, log.WithGroup("issuer"))
if err != nil {
log.With(zap.Error(err)).Fatalf("Failed to create issuer")
log.With(slog.Any("error", err)).Error("Failed to create issuer")
os.Exit(1)
}
server := server.New(log.Named("server"), issuer)
server := server.New(log.WithGroup("server"), issuer)
httpListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortHTTP)))
if err != nil {
log.With(zap.Error(err), zap.Int("port", constants.VerifyServicePortHTTP)).
Fatalf("Failed to listen")
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortHTTP)).
Error("Failed to listen")
os.Exit(1)
}
grpcListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortGRPC)))
if err != nil {
log.With(zap.Error(err), zap.Int("port", constants.VerifyServicePortGRPC)).
Fatalf("Failed to listen")
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortGRPC)).
Error("Failed to listen")
os.Exit(1)
}
if err := server.Run(httpListener, grpcListener); err != nil {
log.With(zap.Error(err)).Fatalf("Failed to run server")
log.With(slog.Any("error", err)).Error("Failed to run server")
os.Exit(1)
}
}