summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/utils/utils.go
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/utils/utils.go
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/utils/utils.go')
-rw-r--r--src/orchestrator/utils/utils.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/orchestrator/utils/utils.go b/src/orchestrator/utils/utils.go
index 22ce903b..b591ccb5 100644
--- a/src/orchestrator/utils/utils.go
+++ b/src/orchestrator/utils/utils.go
@@ -23,13 +23,14 @@ import (
"io"
"io/ioutil"
- "log"
"os"
"path"
"path/filepath"
pkgerrors "github.com/pkg/errors"
yaml "gopkg.in/yaml.v3"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+
)
// ListYamlStruct is applied when the kind is list
@@ -69,15 +70,15 @@ type YamlStruct struct {
func (y YamlStruct) isValid() bool {
if y.APIVersion == "" {
- log.Printf("apiVersion is missing in manifest file")
+ log.Info("apiVersion is missing in manifest file", log.Fields{})
return false
}
if y.Kind == "" {
- log.Printf("kind is missing in manifest file")
+ log.Info("kind is missing in manifest file", log.Fields{})
return false
}
if y.Metadata.Name == "" {
- log.Printf("metadata.name is missing in manifest file")
+ log.Info("metadata.name is missing in manifest file", log.Fields{})
return false
}
return true
@@ -107,13 +108,14 @@ func ExtractYamlParameters(f string) (YamlStruct, error) {
li := strings.LastIndex(filename, "/")
fn := string(filename[li+1:])
yamlStruct.Metadata.Name = fn
- log.Printf("Setting the metadata name as :: %s", fn)
+ log.Info("Setting the metadata", log.Fields{"MetaDataName":fn})
}
if yamlStruct.isValid() {
- log.Printf("YAML parameters for file ::%s \n %v", f, yamlStruct)
+ log.Info(":: YAML parameters ::", log.Fields{"fileName": f, "yamlStruct":yamlStruct})
+
return yamlStruct, nil
}
- log.Printf("YAML file ::%s has errors", f)
+ log.Info("YAML file has errors", log.Fields{"fileName": f})
return YamlStruct{}, pkgerrors.Errorf("Cant extract parameters from yaml file :: %s", filename)
}
@@ -204,13 +206,3 @@ func EnsureDirectory(f string) error {
}
return os.MkdirAll(base, 0755)
}
-
-// func main() {
-// filename := "./test.yaml"
-// yamlStruct, err := ExtractYamlParameters(filename)
-// if err!=nil {
-// log.Print(err)
-// }
-// fmt.Printf("%s+%s", yamlStruct.Metadata.Name, yamlStruct.Kind)
-// fmt.Printf("%v", yamlStruct)
-// }