aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-09-10 23:47:04 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-10 23:47:04 +0000
commit172bebb96ce3ef47f5514c5f7a9a2b70d583f31c (patch)
tree514b4c834e01da0a064536bd8f68ee6ed83c35b9 /src/orchestrator/pkg
parentdae8d6f81bf346b3e63d939081b80c269e925e50 (diff)
parent4759e43ff7f29727477b0d928047bf5ca283cef1 (diff)
Merge "Add log level support for orchestrator"
Diffstat (limited to 'src/orchestrator/pkg')
-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)
}
+