summaryrefslogtreecommitdiffstats
path: root/certServiceK8sExternalProvider/main.go
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-10-30 17:06:04 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-11-05 13:53:05 +0100
commit5fe9e1b7c43fc1a34b38899a2a055540cc30ac81 (patch)
tree5a83d0219fa03f0d280db61ed44f64d377a04138 /certServiceK8sExternalProvider/main.go
parent15446c2ccfc117a0feb5a5249c2e62714b2cd3d7 (diff)
[OOM-K8S-CERT-EXTERNAL-PROVIDER] Change logger implementation provider
Issue-ID: OOM-2559 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com> Change-Id: I717dfcfd74a01ccb81b2eb03c52be2c90fc3a9c5
Diffstat (limited to 'certServiceK8sExternalProvider/main.go')
-rw-r--r--certServiceK8sExternalProvider/main.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/certServiceK8sExternalProvider/main.go b/certServiceK8sExternalProvider/main.go
index 430d4020..c649e3fc 100644
--- a/certServiceK8sExternalProvider/main.go
+++ b/certServiceK8sExternalProvider/main.go
@@ -36,32 +36,35 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/utils/clock"
ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
app "onap.org/oom-certservice/k8s-external-provider/src"
certserviceapi "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api"
controllers "onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller"
"onap.org/oom-certservice/k8s-external-provider/src/cmpv2provisioner"
+ "onap.org/oom-certservice/k8s-external-provider/src/leveledlogger"
)
var (
scheme = runtime.NewScheme()
- setupLog = ctrl.Log.WithName("setup")
+ setupLog leveledlogger.Logger
)
func init() {
_ = clientgoscheme.AddToScheme(scheme)
_ = certmanager.AddToScheme(scheme)
_ = certserviceapi.AddToScheme(scheme)
+ setupLog = leveledlogger.GetLogger()
- ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
+ ctrl.SetLogger(setupLog.Log)
}
func main() {
printVersionInfo()
- metricsAddr, enableLeaderElection := parseInputArguments()
+ metricsAddr, logLevel, enableLeaderElection := parseInputArguments()
+
+ leveledlogger.SetLogLevel(logLevel)
manager := createControllerManager(metricsAddr, enableLeaderElection)
@@ -79,15 +82,17 @@ func printVersionInfo() {
fmt.Println()
}
-func parseInputArguments() (string, bool) {
+func parseInputArguments() (string, string, bool) {
setupLog.Info("Parsing input arguments...")
var metricsAddr string
+ var logLevel string
var enableLeaderElection bool
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
+ flag.StringVar(&logLevel, "log-level", "debug", "Min. level for logs visibility. One of: debug, info, warn, error")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
flag.Parse()
- return metricsAddr, enableLeaderElection
+ return metricsAddr, logLevel, enableLeaderElection
}
func startControllerManager(manager manager.Manager) {
@@ -115,7 +120,7 @@ func registerCMPv2IssuerController(manager manager.Manager) {
err := (&controllers.CMPv2IssuerController{
Client: manager.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("CMPv2Issuer"),
+ Log: leveledlogger.GetLoggerWithValues("controllers", "CMPv2Issuer"),
Clock: clock.RealClock{},
Recorder: manager.GetEventRecorderFor("cmpv2-issuer-controller"),
ProvisionerFactory: &cmpv2provisioner.ProvisionerFactoryImpl{},
@@ -131,7 +136,7 @@ func registerCertificateRequestController(manager manager.Manager) {
err := (&controllers.CertificateRequestController{
Client: manager.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("CertificateRequest"),
+ Log: leveledlogger.GetLoggerWithValues("controllers", "CertificateRequest"),
Recorder: manager.GetEventRecorderFor("certificate-requests-controller"),
}).SetupWithManager(manager)