Skip to content

Commit

Permalink
added util.go changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoaeb Jindani committed Apr 2, 2024
1 parent f582637 commit e16d7cc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import (
"github.com/IBM-Blockchain/fabric-operator/pkg/k8s/clientset"
routev1 "github.com/openshift/api/route/v1"
"github.com/pkg/errors"
uberzap "go.uber.org/zap"
"go.uber.org/zap/zapcore"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
Expand Down Expand Up @@ -942,3 +944,24 @@ func GetServerVersion() (*version.Info, error) {
}
return version, nil
}

func SetupLogging(loglevel string) (*uberzap.Logger, error) {
// set up logging
var level zapcore.Level
err := level.Set(loglevel)
if err != nil {
return nil, err
}
zapConfig := uberzap.NewProductionConfig()
zapConfig.Level = uberzap.NewAtomicLevelAt(level)
zapConfig.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
logger, err := zapConfig.Build()
defer logger.Sync()
if err != nil {
return nil, err
}
// redirect uses of standard logger
uberzap.RedirectStdLog(logger)

return logger, nil
}

0 comments on commit e16d7cc

Please sign in to comment.