VOL-1848 loglevel commands
Change-Id: I0db607e85d9a53220438fd999c1fa3cf53516ed7
diff --git a/pkg/model/loglevel.go b/pkg/model/loglevel.go
new file mode 100644
index 0000000..c125c9b
--- /dev/null
+++ b/pkg/model/loglevel.go
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2019-present Ciena Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package model
+
+import (
+ "github.com/jhump/protoreflect/dynamic"
+)
+
+type LogLevel struct {
+ ComponentName string
+ PackageName string
+ Level string
+}
+
+func (logLevel *LogLevel) PopulateFrom(val *dynamic.Message) {
+ logLevel.ComponentName = val.GetFieldByName("component_name").(string)
+ logLevel.PackageName = val.GetFieldByName("package_name").(string)
+ logLevel.Level = GetEnumValue(val, "level") //val.GetFieldByName("level").(string)
+}
diff --git a/pkg/model/utils.go b/pkg/model/utils.go
index b885ae0..d30324f 100644
--- a/pkg/model/utils.go
+++ b/pkg/model/utils.go
@@ -23,3 +23,8 @@
return val.FindFieldDescriptorByName(name).GetEnumType().
FindValueByNumber(val.GetFieldByName(name).(int32)).GetName()
}
+
+func SetEnumValue(msg *dynamic.Message, name string, value string) {
+ eValue := msg.FindFieldDescriptorByName(name).GetEnumType().FindValueByName(value)
+ msg.SetFieldByName(name, eValue.GetNumber())
+}