diff --git a/internal/logger/grpclogger.go b/internal/logger/grpclogger.go index 125169bb5..bf96c4eb6 100644 --- a/internal/logger/grpclogger.go +++ b/internal/logger/grpclogger.go @@ -94,6 +94,9 @@ func (l *grpcLogger) Errorf(format string, args ...interface{}) { } // TODO(miampf): Find a way to log on a fatal level, not an error level? +// A ReplaceAttr function could be implemented in the logger package, however +// this would increase it's complexity again (look [here](https://pkg.go.dev/log/slog#HandlerOptions) +// for a reference implementation. func (l *grpcLogger) Fatal(args ...interface{}) { var pcs [1]uintptr diff --git a/internal/logger/log.go b/internal/logger/log.go index 21fa76a96..19f4c51eb 100644 --- a/internal/logger/log.go +++ b/internal/logger/log.go @@ -50,12 +50,6 @@ import ( "google.golang.org/grpc" ) -// TODO(miampf): maybe rewrite as a solution for increasing log level? -// WithIncreasedLevel returns a logger with increased logging level. -// func (l *Logger) WithIncreasedLevel(level zapcore.Level) *Logger { -// return &Logger{logger: l.getZapLogger().WithOptions(zap.IncreaseLevel(level)).Sugar()} -// } - // ReplaceGRPCLogger replaces grpc's internal logger with the given logger. func ReplaceGRPCLogger(l *slog.Logger) { replaceGRPCLogger(l) diff --git a/keyservice/internal/server/server.go b/keyservice/internal/server/server.go index f54254510..8d652b5c1 100644 --- a/keyservice/internal/server/server.go +++ b/keyservice/internal/server/server.go @@ -51,8 +51,11 @@ func (s *Server) Run(port string) error { server := grpc.NewServer(logger.GetServerUnaryInterceptor(s.log.WithGroup("gRPC"))) keyserviceproto.RegisterAPIServer(server, s) - // TODO(miampf): Find out a good way to pass an increased Level to slog - s.log.WithGroup("gRPC").WithIncreasedLevel(zapcore.WarnLevel).ReplaceGRPCLogger() + // TODO(miampf): Find out a good way to pass an increased Level to slog. + // A reference implementation for something like that exists + // [here](https://pkg.go.dev/log/slog#Handler), however, this would + // utilise structs in the logger package again which is not optimal. + logger.ReplaceGRPCLogger(s.log.WithGroup("gRPC").WithIncreasedLevel(zapcore.WarnLevel)) // start the server s.log.Info("Starting Constellation key management service on %s", listener.Addr().String()) diff --git a/operators/constellation-node-operator/main.go b/operators/constellation-node-operator/main.go index 07e3b303b..dcc61f3c9 100644 --- a/operators/constellation-node-operator/main.go +++ b/operators/constellation-node-operator/main.go @@ -75,6 +75,7 @@ func main() { flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") + // TODO(miampf): Find out what is going on here and reimplement it in log/slog. opts := zap.Options{ Development: true, }