From 8fe3631f405f1b67dda7d423947012608eab194b Mon Sep 17 00:00:00 2001 From: Mikhail Avramenko Date: Thu, 7 Oct 2021 18:51:55 +0700 Subject: [PATCH] Added config option for log level Signed-off-by: Mikhail Avramenko --- internal/prefixcollector/config.go | 3 ++- main.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/prefixcollector/config.go b/internal/prefixcollector/config.go index 918ec8d..3ae0601 100644 --- a/internal/prefixcollector/config.go +++ b/internal/prefixcollector/config.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -37,6 +37,7 @@ type Config struct { NSMConfigMapName string `default:"nsm-config" desc:"Name of nsm config map" split_words:"true"` OutputFilePath string `default:"/var/lib/networkservicemesh/config/excluded_prefixes.yaml" desc:"Path of output prefixes file" split_words:"true"` PrefixesOutputType string `default:"file" desc:"Where to write excluded prefixes" split_words:"true"` + LogLevel string `default:"INFO" desc:"Log level" split_words:"true"` } // Validate - validates config. Checks PrefixesOutputType and every CIDR from config.ExcludedPrefixes. diff --git a/main.go b/main.go index a11cafa..562634f 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ import ( "github.com/networkservicemesh/sdk-k8s/pkg/k8s" "github.com/kelseyhightower/envconfig" + "github.com/sirupsen/logrus" "k8s.io/client-go/kubernetes" "github.com/networkservicemesh/sdk/pkg/tools/jaeger" @@ -70,6 +71,12 @@ func main() { span.Logger().Fatalf("Error validating Config from env: %v", err) } + level, err := logrus.ParseLevel(config.LogLevel) + if err != nil { + logrus.Fatalf("invalid log level %s", config.LogLevel) + } + logrus.SetLevel(level) + span.Logger().Info("Building Kubernetes clientSet...") clientSetConfig, err := k8s.NewClientSetConfig() if err != nil {