aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/infra
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-08-29 02:47:00 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-09-09 21:25:53 +0000
commit4759e43ff7f29727477b0d928047bf5ca283cef1 (patch)
treeebed9009ab8bcb28aeb07b495eab08a161150299 /src/orchestrator/pkg/infra
parentbca6932e54ff0495947d8a4f1862339a69d386f8 (diff)
Add log level support for orchestrator
In this patch, a new config item for log-level is added, default log-level is set as "warn", for detailed logs, set log-level as "info" Issue-ID: MULTICLOUD-1200 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: I3205ce110a492ecc6a7c680e3d35e173a5624bb0
Diffstat (limited to 'src/orchestrator/pkg/infra')
-rw-r--r--src/orchestrator/pkg/infra/config/config.go3
-rw-r--r--src/orchestrator/pkg/infra/logutils/logger.go11
2 files changed, 14 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/infra/config/config.go b/src/orchestrator/pkg/infra/config/config.go
index fca8bfbd..43191489 100644
--- a/src/orchestrator/pkg/infra/config/config.go
+++ b/src/orchestrator/pkg/infra/config/config.go
@@ -44,6 +44,7 @@ type Configuration struct {
GrpcServerNameOverride string `json:"grpc-server-name-override"`
ServicePort string `json:"service-port"`
KubernetesLabelName string `json:"kubernetes-label-name"`
+ LogLevel string `json:"log-level"`
}
// Config is the structure that stores the configuration
@@ -98,6 +99,8 @@ func defaultConfiguration() *Configuration {
GrpcServerNameOverride: "",
ServicePort: "9015",
KubernetesLabelName: "orchestrator.io/rb-instance-id",
+ LogLevel: "warn",
+
}
}
diff --git a/src/orchestrator/pkg/infra/logutils/logger.go b/src/orchestrator/pkg/infra/logutils/logger.go
index 2e8f9969..209114a3 100644
--- a/src/orchestrator/pkg/infra/logutils/logger.go
+++ b/src/orchestrator/pkg/infra/logutils/logger.go
@@ -2,6 +2,9 @@ package logutils
import (
log "github.com/sirupsen/logrus"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/config"
+ "strings"
+
)
//Fields is type that will be used by the calling function
@@ -10,6 +13,13 @@ type Fields map[string]interface{}
func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
+ if strings.EqualFold(config.GetConfiguration().LogLevel, "warn") {
+ log.SetLevel(log.WarnLevel)
+
+ }
+ if strings.EqualFold(config.GetConfiguration().LogLevel, "info") {
+ log.SetLevel(log.InfoLevel)
+ }
}
// Error uses the fields provided and logs
@@ -26,3 +36,4 @@ func Warn(msg string, fields Fields) {
func Info(msg string, fields Fields) {
log.WithFields(log.Fields(fields)).Info(msg)
}
+