From c1f00b7d54ecd16ede9687b8cdb1d6517180e7c9 Mon Sep 17 00:00:00 2001 From: Mohamed Abukar Date: Wed, 25 Nov 2020 13:51:00 +0200 Subject: [PATCH] API update Change-Id: Iefb91e5d5690d2950e3203099b40ab370e1680a2 Signed-off-by: Mohamed Abukar --- pkg/xapp/config.go | 4 ++++ pkg/xapp/logger.go | 4 ++++ pkg/xapp/xapp_test.go | 2 ++ 3 files changed, 10 insertions(+) diff --git a/pkg/xapp/config.go b/pkg/xapp/config.go index 2260153..11daf4f 100755 --- a/pkg/xapp/config.go +++ b/pkg/xapp/config.go @@ -209,3 +209,7 @@ func (*Configurator) GetStringSlice(key string) []string { func (*Configurator) GetStringMap(key string) map[string]interface{} { return viper.GetStringMap(key) } + +func (*Configurator) IsSet(key string) bool { + return viper.IsSet(key) +} diff --git a/pkg/xapp/logger.go b/pkg/xapp/logger.go index 69bed09..226a909 100755 --- a/pkg/xapp/logger.go +++ b/pkg/xapp/logger.go @@ -48,6 +48,10 @@ func (l *Log) SetMdc(key string, value string) { l.logger.MdcAdd(key, value) } +func (l *Log) GetLevel() mdclog.Level { + return l.logger.LevelGet() +} + func (l *Log) Error(pattern string, args ...interface{}) { if l.logger.LevelGet() < mdclog.ERR { return diff --git a/pkg/xapp/xapp_test.go b/pkg/xapp/xapp_test.go index 4361491..04bbbb8 100755 --- a/pkg/xapp/xapp_test.go +++ b/pkg/xapp/xapp_test.go @@ -340,6 +340,7 @@ func TestConfigAccess(t *testing.T) { Config.Get("controls") Config.GetStringSlice("messaging.ports") Config.GetStringMap("messaging.ports") + Config.IsSet("messaging") } func TestPublishConfigChange(t *testing.T) { @@ -412,6 +413,7 @@ func TestRnibInterfaces(t *testing.T) { func TestLogger(t *testing.T) { Logger.Error("CASE: TestNewSubscriber") Logger.Warn("CASE: TestNewSubscriber") + Logger.GetLevel() } func TestConfigHandler(t *testing.T) { -- 2.16.6