From a52245feace90df13e23a76c073584f138082764 Mon Sep 17 00:00:00 2001 From: gab-arrobo Date: Wed, 2 Oct 2024 16:06:09 -0700 Subject: [PATCH] Replace `logrus` with `zap` logger (#224) Signed-off-by: Arrobo, Gabriel --- VERSION | 2 +- backend/factory/factory.go | 5 +- backend/logger/logger.go | 91 +++++++++++++++-------------- backend/webui_service/webui_init.go | 67 ++++++++------------- configapi/api_slice_mgmt.go | 4 +- go.mod | 16 ++--- go.sum | 51 ++++++---------- proto/server/clientEvtHandler.go | 11 ++-- proto/server/configEvtHandler.go | 32 +++++----- proto/server/gServer.go | 6 +- server.go | 6 +- 11 files changed, 129 insertions(+), 162 deletions(-) diff --git a/VERSION b/VERSION index 2847639f..bc80560f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.4-dev +1.5.0 diff --git a/backend/factory/factory.go b/backend/factory/factory.go index e54f2ed2..c888148c 100644 --- a/backend/factory/factory.go +++ b/backend/factory/factory.go @@ -15,6 +15,7 @@ import ( "fmt" "os" + "github.com/omec-project/webconsole/backend/logger" "gopkg.in/yaml.v2" ) @@ -46,11 +47,11 @@ func InitConfigFactory(f string) error { // we dont want Mode5G coming from the helm chart, since // there is chance of misconfiguration if os.Getenv("CONFIGPOD_DEPLOYMENT") == "4G" { - fmt.Println("ConfigPod running in 4G deployment") + logger.ConfigLog.Infoln("configPod running in 4G deployment") WebUIConfig.Configuration.Mode5G = false } else { // default mode - fmt.Println("ConfigPod running in 5G deployment") + logger.ConfigLog.Infoln("configPod running in 5G deployment") WebUIConfig.Configuration.Mode5G = true } } diff --git a/backend/logger/logger.go b/backend/logger/logger.go index 3c38e861..322a1797 100644 --- a/backend/logger/logger.go +++ b/backend/logger/logger.go @@ -7,64 +7,65 @@ package logger import ( - "os" - "time" - - formatter "github.com/antonfisher/nested-logrus-formatter" - logger_util "github.com/omec-project/util/logger" - "github.com/omec-project/util/logger_conf" - "github.com/sirupsen/logrus" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) var ( - log *logrus.Logger - AppLog *logrus.Entry - InitLog *logrus.Entry - WebUILog *logrus.Entry - ContextLog *logrus.Entry - GinLog *logrus.Entry - GrpcLog *logrus.Entry - ConfigLog *logrus.Entry - DbLog *logrus.Entry + log *zap.Logger + AppLog *zap.SugaredLogger + InitLog *zap.SugaredLogger + WebUILog *zap.SugaredLogger + ContextLog *zap.SugaredLogger + GinLog *zap.SugaredLogger + GrpcLog *zap.SugaredLogger + ConfigLog *zap.SugaredLogger + DbLog *zap.SugaredLogger + atomicLevel zap.AtomicLevel ) func init() { - log = logrus.New() - log.SetReportCaller(false) - - log.Formatter = &formatter.Formatter{ - TimestampFormat: time.RFC3339, - TrimMessages: true, - NoFieldsSpace: true, - HideKeys: true, - FieldsOrder: []string{"component", "category"}, + atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel) + config := zap.Config{ + Level: atomicLevel, + Development: false, + Encoding: "console", + EncoderConfig: zap.NewProductionEncoderConfig(), + OutputPaths: []string{"stdout"}, + ErrorOutputPaths: []string{"stderr"}, } - free5gcLogHook, err := logger_util.NewFileHook(logger_conf.Free5gcLogFile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(free5gcLogHook) - } + config.EncoderConfig.TimeKey = "timestamp" + config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + config.EncoderConfig.LevelKey = "level" + config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + config.EncoderConfig.CallerKey = "caller" + config.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder + config.EncoderConfig.MessageKey = "message" + config.EncoderConfig.StacktraceKey = "" - selfLogHook, err := logger_util.NewFileHook( - logger_conf.Free5gcLogDir+"webconsole.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(selfLogHook) + var err error + log, err = config.Build() + if err != nil { + panic(err) } - AppLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "App"}) - InitLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "Init"}) - WebUILog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "WebUI"}) - ContextLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "Context"}) - GinLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "GIN"}) - GrpcLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "GRPC"}) - ConfigLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "CONFIG"}) - DbLog = log.WithFields(logrus.Fields{"component": "WebUI", "category": "DB"}) + AppLog = log.Sugar().With("component", "WebUI", "category", "App") + InitLog = log.Sugar().With("component", "WebUI", "category", "Init") + WebUILog = log.Sugar().With("component", "WebUI", "category", "WebUI") + ContextLog = log.Sugar().With("component", "WebUI", "category", "Context") + GinLog = log.Sugar().With("component", "WebUI", "category", "GIN") + GrpcLog = log.Sugar().With("component", "WebUI", "category", "GRPC") + ConfigLog = log.Sugar().With("component", "WebUI", "category", "CONFIG") + DbLog = log.Sugar().With("component", "WebUI", "category", "DB") } -func SetLogLevel(level logrus.Level) { - log.SetLevel(level) +func GetLogger() *zap.Logger { + return log } -func SetReportCaller(set bool) { - log.SetReportCaller(set) +// SetLogLevel: set the log level (panic|fatal|error|warn|info|debug) +func SetLogLevel(level zapcore.Level) { + InitLog.Infoln("set log level:", level) + atomicLevel.SetLevel(level) } diff --git a/backend/webui_service/webui_init.go b/backend/webui_service/webui_init.go index 120eb537..542ecfd8 100644 --- a/backend/webui_service/webui_init.go +++ b/backend/webui_service/webui_init.go @@ -19,9 +19,8 @@ import ( "github.com/gin-contrib/cors" "github.com/omec-project/util/http2_util" - loggerUtil "github.com/omec-project/util/logger" + utilLogger "github.com/omec-project/util/logger" "github.com/omec-project/util/path_util" - pathUtilLogger "github.com/omec-project/util/path_util/logger" "github.com/omec-project/webconsole/backend/factory" "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/backend/metrics" @@ -30,8 +29,9 @@ import ( "github.com/omec-project/webconsole/configmodels" "github.com/omec-project/webconsole/dbadapter" gServ "github.com/omec-project/webconsole/proto/server" - "github.com/sirupsen/logrus" "github.com/urfave/cli" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) type WEBUI struct{} @@ -56,7 +56,7 @@ var webuiCLi = []cli.Flag{ }, } -var initLog *logrus.Entry +var initLog *zap.SugaredLogger func init() { initLog = logger.InitLog @@ -93,51 +93,33 @@ func (webui *WEBUI) setLogLevel() { if factory.WebUIConfig.Logger.WEBUI != nil { if factory.WebUIConfig.Logger.WEBUI.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.WebUIConfig.Logger.WEBUI.DebugLevel); err != nil { + if level, err := zapcore.ParseLevel(factory.WebUIConfig.Logger.WEBUI.DebugLevel); err != nil { initLog.Warnf("WebUI Log level [%s] is invalid, set to [info] level", factory.WebUIConfig.Logger.WEBUI.DebugLevel) - logger.SetLogLevel(logrus.InfoLevel) + logger.SetLogLevel(zap.InfoLevel) } else { initLog.Infof("WebUI Log level is set to [%s] level", level) logger.SetLogLevel(level) } } else { initLog.Warnln("WebUI Log level not set. Default set to [info] level") - logger.SetLogLevel(logrus.InfoLevel) + logger.SetLogLevel(zap.InfoLevel) } - logger.SetReportCaller(factory.WebUIConfig.Logger.WEBUI.ReportCaller) - } - - if factory.WebUIConfig.Logger.PathUtil != nil { - if factory.WebUIConfig.Logger.PathUtil.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.WebUIConfig.Logger.PathUtil.DebugLevel); err != nil { - pathUtilLogger.PathLog.Warnf("PathUtil Log level [%s] is invalid, set to [info] level", - factory.WebUIConfig.Logger.PathUtil.DebugLevel) - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } else { - pathUtilLogger.SetLogLevel(level) - } - } else { - pathUtilLogger.PathLog.Warnln("PathUtil Log level not set. Default set to [info] level") - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } - pathUtilLogger.SetReportCaller(factory.WebUIConfig.Logger.PathUtil.ReportCaller) } if factory.WebUIConfig.Logger.MongoDBLibrary != nil { if factory.WebUIConfig.Logger.MongoDBLibrary.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.WebUIConfig.Logger.MongoDBLibrary.DebugLevel); err != nil { - loggerUtil.AppLog.Warnf("MongoDBLibrary Log level [%s] is invalid, set to [info] level", + if level, err := zapcore.ParseLevel(factory.WebUIConfig.Logger.MongoDBLibrary.DebugLevel); err != nil { + utilLogger.AppLog.Warnf("MongoDBLibrary Log level [%s] is invalid, set to [info] level", factory.WebUIConfig.Logger.MongoDBLibrary.DebugLevel) - loggerUtil.SetLogLevel(logrus.InfoLevel) + utilLogger.SetLogLevel(zap.InfoLevel) } else { - loggerUtil.SetLogLevel(level) + utilLogger.SetLogLevel(level) } } else { - loggerUtil.AppLog.Warnln("MongoDBLibrary Log level not set. Default set to [info] level") - loggerUtil.SetLogLevel(logrus.InfoLevel) + utilLogger.AppLog.Warnln("MongoDBLibrary Log level not set. Default set to [info] level") + utilLogger.SetLogLevel(zap.InfoLevel) } - loggerUtil.SetReportCaller(factory.WebUIConfig.Logger.MongoDBLibrary.ReportCaller) } } @@ -166,7 +148,7 @@ func (webui *WEBUI) Start() { initLog.Infoln("WebUI Server started") /* First HTTP Server running at port to receive Config from ROC */ - subconfig_router := loggerUtil.NewGinWithLogrus(logger.GinLog) + subconfig_router := utilLogger.NewGinWithZap(logger.GinLog) AddSwaggerUiService(subconfig_router) AddUiService(subconfig_router) configapi.AddServiceSub(subconfig_router) @@ -237,11 +219,9 @@ func (webui *WEBUI) Start() { } func (webui *WEBUI) Exec(c *cli.Context) error { - // WEBUI.Initialize(cfgPath, c) - - initLog.Traceln("args:", c.String("webuicfg")) + initLog.Debugln("args:", c.String("webuicfg")) args := webui.FilterCli(c) - initLog.Traceln("filter: ", args) + initLog.Debugln("filter:", args) command := exec.Command("./webui", args...) webui.Initialize(c) @@ -255,7 +235,7 @@ func (webui *WEBUI) Exec(c *cli.Context) error { go func() { in := bufio.NewScanner(stdout) for in.Scan() { - fmt.Println(in.Text()) + initLog.Infoln(in.Text()) } wg.Done() }() @@ -267,14 +247,14 @@ func (webui *WEBUI) Exec(c *cli.Context) error { go func() { in := bufio.NewScanner(stderr) for in.Scan() { - fmt.Println(in.Text()) + initLog.Infoln(in.Text()) } wg.Done() }() go func() { if errCmd := command.Start(); errCmd != nil { - fmt.Println("command.Start Fails!") + initLog.Errorln("command.Start Failed") } wg.Done() }() @@ -291,7 +271,6 @@ func fetchConfigAdapater() { (!factory.WebUIConfig.Configuration.RocEnd.Enabled) || (factory.WebUIConfig.Configuration.RocEnd.SyncUrl == "") { time.Sleep(1 * time.Second) - // fmt.Printf("Continue polling config change %v ", factory.WebUIConfig.Configuration) continue } @@ -300,7 +279,7 @@ func fetchConfigAdapater() { req, err := http.NewRequest(http.MethodPost, httpend, nil) // Handle Error if err != nil { - fmt.Printf("An Error Occurred %v\n", err) + initLog.Errorf("an error occurred %v", err) time.Sleep(1 * time.Second) continue } @@ -308,15 +287,15 @@ func fetchConfigAdapater() { req.Header.Set("Content-Type", "application/json; charset=utf-8") resp, err := client.Do(req) if err != nil { - fmt.Printf("An Error Occurred %v\n", err) + initLog.Errorf("an error occurred %v", err) time.Sleep(1 * time.Second) continue } err = resp.Body.Close() if err != nil { - fmt.Printf("An Error Occurred %v\n", err) + initLog.Errorf("an error occurred %v", err) } - fmt.Printf("Fetching config from simapp/roc. Response code = %d \n", resp.StatusCode) + initLog.Infof("fetching config from simapp/roc. Response code = %d", resp.StatusCode) break } } diff --git a/configapi/api_slice_mgmt.go b/configapi/api_slice_mgmt.go index 7c4b25b0..bf19ea7c 100644 --- a/configapi/api_slice_mgmt.go +++ b/configapi/api_slice_mgmt.go @@ -14,7 +14,7 @@ import ( "github.com/omec-project/util/httpwrapper" "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/configmodels" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) const ( @@ -25,7 +25,7 @@ const ( var configChannel chan *configmodels.ConfigMessage -var configLog *logrus.Entry +var configLog *zap.SugaredLogger func init() { configLog = logger.ConfigLog diff --git a/go.mod b/go.mod index da54ab2b..853aa763 100644 --- a/go.mod +++ b/go.mod @@ -3,20 +3,19 @@ module github.com/omec-project/webconsole go 1.21 require ( - github.com/antonfisher/nested-logrus-formatter v1.3.1 github.com/gin-contrib/cors v1.7.2 github.com/gin-gonic/gin v1.10.0 github.com/mitchellh/mapstructure v1.5.0 github.com/omec-project/config5g v1.5.0 github.com/omec-project/openapi v1.3.1 - github.com/omec-project/util v1.1.0 + github.com/omec-project/util v1.2.1 github.com/prometheus/client_golang v1.20.4 - github.com/sirupsen/logrus v1.9.3 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.3 github.com/urfave/cli v1.22.15 - go.mongodb.org/mongo-driver v1.10.1 + go.mongodb.org/mongo-driver v1.17.0 + go.uber.org/zap v1.27.0 google.golang.org/grpc v1.67.0 google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 @@ -56,7 +55,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.6.6 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -67,9 +66,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.1.1 // indirect - github.com/xdg-go/stringprep v1.0.3 // indirect - github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + go.uber.org/multierr v1.10.0 // indirect golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.27.0 // indirect golang.org/x/net v0.29.0 // indirect diff --git a/go.sum b/go.sum index 04389b58..dc25db99 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,6 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= -github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -61,10 +59,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -72,7 +68,6 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -103,9 +98,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -113,8 +107,8 @@ github.com/omec-project/config5g v1.5.0 h1:VC7uHIdg4S4F5onYvpFfaEAFBttWwWh6OSnNn github.com/omec-project/config5g v1.5.0/go.mod h1:yTjqsOjy8KQ8o4AlnPeZfP32CEvlm0kug3bMwZ3IDOQ= github.com/omec-project/openapi v1.3.1 h1:NCteMRdMtWnMhf1CXYduuLgeu8fEhc/7XO1CiE7fN3Y= github.com/omec-project/openapi v1.3.1/go.mod h1:cR6Iharp2TLOzEmskQ/EdCVFZnpKh0zTvUSSuyXAYLE= -github.com/omec-project/util v1.1.0 h1:TUuLmzqTLChIEXQlK9g5Ihgmw4FUm/UJnjfu0wT8Gz0= -github.com/omec-project/util v1.1.0/go.mod h1:BEv8nCokB4j0fgAQ6VVkKuQ2PSP3DJMEmz25pFMw5X8= +github.com/omec-project/util v1.2.1 h1:+o5kbnZzKBmbqT4oprVGPgL0jH5b8BvRMfLye5srGQ4= +github.com/omec-project/util v1.2.1/go.mod h1:kUF2LXhmtw+m7Bk5IGOMFLj7CA8VKtilLI/9QBJcfxE= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -133,8 +127,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -154,8 +146,6 @@ github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+z github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= @@ -164,50 +154,47 @@ github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM= github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= -github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= -go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= +go.mongodb.org/mongo-driver v1.17.0 h1:Hp4q2MCjvY19ViwimTs00wHi7G4yzxh4/2+nTx8r40k= +go.mongodb.org/mongo-driver v1.17.0/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -220,6 +207,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= @@ -229,7 +217,6 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= diff --git a/proto/server/clientEvtHandler.go b/proto/server/clientEvtHandler.go index 7fc99e0c..506a5245 100644 --- a/proto/server/clientEvtHandler.go +++ b/proto/server/clientEvtHandler.go @@ -18,7 +18,7 @@ import ( "github.com/omec-project/webconsole/backend/factory" "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/configmodels" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) type clientNF struct { @@ -28,7 +28,7 @@ type clientNF struct { tempGrpcReq chan *clientReqMsg resStream protos.ConfigService_NetworkSliceSubscribeServer resChannel chan bool - clientLog *logrus.Entry + clientLog *zap.SugaredLogger id string ConfigPushUrl string ConfigCheckUrl string @@ -204,13 +204,12 @@ func setClientConfigCheckUrl(client *clientNF, url string) { func getClient(id string) (*clientNF, bool) { client := clientNFPool[id] if client != nil { - client.clientLog.Infof("Found client %v ", id) + client.clientLog.Infof("Found client %v", id) return client, false } - logger.GrpcLog.Printf("Created client %v ", id) + logger.GrpcLog.Infof("created client %v", id) client = &clientNF{} - subField := logrus.Fields{"NF": id} - client.clientLog = grpcLog.WithFields(subField) + client.clientLog = grpcLog.With("NF", id) client.id = id client.outStandingPushConfig = make(chan *configmodels.ConfigMessage, 10) client.tempGrpcReq = make(chan *clientReqMsg, 10) diff --git a/proto/server/configEvtHandler.go b/proto/server/configEvtHandler.go index a889b1e6..b72eae41 100644 --- a/proto/server/configEvtHandler.go +++ b/proto/server/configEvtHandler.go @@ -15,8 +15,8 @@ import ( "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/configmodels" "github.com/omec-project/webconsole/dbadapter" - "github.com/sirupsen/logrus" "go.mongodb.org/mongo-driver/bson" + "go.uber.org/zap" ) const ( @@ -33,7 +33,7 @@ const ( upfDataColl = "webconsoleData.snapshots.upfData" ) -var configLog *logrus.Entry +var configLog *zap.SugaredLogger func init() { configLog = logger.ConfigLog @@ -277,7 +277,7 @@ func getDeviceGroups() []*configmodels.DeviceGroups { var devGroupData configmodels.DeviceGroups err := json.Unmarshal(mapToByte(rawDevGroup), &devGroupData) if err != nil { - logger.DbLog.Errorf("Could not unmarshall device group %v", rawDevGroup) + logger.DbLog.Errorf("could not unmarshall device group %v", rawDevGroup) } deviceGroups = append(deviceGroups, &devGroupData) } @@ -293,7 +293,7 @@ func getDeviceGroupByName(name string) *configmodels.DeviceGroups { var devGroupData configmodels.DeviceGroups err := json.Unmarshal(mapToByte(devGroupDataInterface), &devGroupData) if err != nil { - logger.DbLog.Errorf("Could not unmarshall device group %v", devGroupDataInterface) + logger.DbLog.Errorf("could not unmarshall device group %v", devGroupDataInterface) } return &devGroupData } @@ -308,7 +308,7 @@ func getSlices() []*configmodels.Slice { var sliceData configmodels.Slice err := json.Unmarshal(mapToByte(rawSlice), &sliceData) if err != nil { - logger.DbLog.Errorf("Could not unmarshall slice %v", rawSlice) + logger.DbLog.Errorf("could not unmarshall slice %v", rawSlice) } slices = append(slices, &sliceData) } @@ -324,7 +324,7 @@ func getSliceByName(name string) *configmodels.Slice { var sliceData configmodels.Slice err := json.Unmarshal(mapToByte(sliceDataInterface), &sliceData) if err != nil { - logger.DbLog.Errorf("Could not unmarshall slice %v", sliceDataInterface) + logger.DbLog.Errorf("could not unmarshall slice %v", sliceDataInterface) } return &sliceData } @@ -512,7 +512,7 @@ func isDeviceGroupExistInSlice(msg *Update5GSubscriberMsg) *configmodels.Slice { for name, slice := range getSlices() { for _, dgName := range slice.SiteDeviceGroup { if dgName == msg.Msg.DevGroupName { - logger.WebUILog.Infof("Device Group [%v] is part of slice: %v", dgName, name) + logger.WebUILog.Infof("device Group [%v] is part of slice: %v", dgName, name) return slice } } @@ -558,7 +558,7 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { // check this Imsi is part of any of the devicegroup imsi := strings.ReplaceAll(confData.Msg.Imsi, "imsi-", "") if confData.Msg.MsgMethod != configmodels.Delete_op { - logger.WebUILog.Debugln("Insert/Update AuthenticationSubscription ", imsi) + logger.WebUILog.Debugln("insert/update AuthenticationSubscription ", imsi) filter := bson.M{"ueId": confData.Msg.Imsi} authDataBsonA := toBsonM(confData.Msg.AuthSubData) authDataBsonA["ueId"] = confData.Msg.Imsi @@ -567,7 +567,7 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { logger.DbLog.Warnln(errPost) } } else { - logger.WebUILog.Debugln("Delete AuthenticationSubscription", imsi) + logger.WebUILog.Debugln("delete AuthenticationSubscription", imsi) filter := bson.M{"ueId": "imsi-" + imsi} errDelOne := dbadapter.AuthDBClient.RestfulAPIDeleteOne(authSubsDataColl, filter) if errDelOne != nil { @@ -587,7 +587,7 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { if slice != nil { sVal, err := strconv.ParseUint(slice.SliceId.Sst, 10, 32) if err != nil { - logger.DbLog.Errorf("Could not parse SST %v", slice.SliceId.Sst) + logger.DbLog.Errorf("could not parse SST %v", slice.SliceId.Sst) } snssai := &models.Snssai{ Sd: slice.SliceId.Sd, @@ -636,15 +636,15 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { case configmodels.Network_slice: rwLock.RLock() - logger.WebUILog.Debugln("Insert/Update Network Slice") + logger.WebUILog.Debugln("insert/update Network Slice") slice := confData.Msg.Slice if slice == nil && confData.PrevSlice != nil { - logger.WebUILog.Debugln("Deleted Slice: ", confData.PrevSlice) + logger.WebUILog.Debugln("deleted Slice:", confData.PrevSlice) } if slice != nil { sVal, err := strconv.ParseUint(slice.SliceId.Sst, 10, 32) if err != nil { - logger.DbLog.Errorf("Could not parse SST %v", slice.SliceId.Sst) + logger.DbLog.Errorf("could not parse SST %v", slice.SliceId.Sst) } snssai := &models.Snssai{ Sd: slice.SliceId.Sd, @@ -728,12 +728,12 @@ func convertToString(val uint64) string { func toBsonM(data interface{}) (ret bson.M) { tmp, err := json.Marshal(data) if err != nil { - logger.DbLog.Errorln("Could not marshall data") + logger.DbLog.Errorln("could not marshall data") return nil } err = json.Unmarshal(tmp, &ret) if err != nil { - logger.DbLog.Errorln("Could not unmarshall data") + logger.DbLog.Errorln("could not unmarshall data") return nil } return ret @@ -742,7 +742,7 @@ func toBsonM(data interface{}) (ret bson.M) { func mapToByte(data map[string]interface{}) (ret []byte) { ret, err := json.Marshal(data) if err != nil { - logger.DbLog.Errorln("Could not marshall data") + logger.DbLog.Errorln("could not marshall data") return nil } return ret diff --git a/proto/server/gServer.go b/proto/server/gServer.go index e97e2875..4e2b980a 100644 --- a/proto/server/gServer.go +++ b/proto/server/gServer.go @@ -15,12 +15,12 @@ import ( "github.com/omec-project/webconsole/backend/factory" "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/configmodels" - "github.com/sirupsen/logrus" + "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" ) -var grpcLog *logrus.Entry +var grpcLog *zap.SugaredLogger func init() { grpcLog = logger.GrpcLog @@ -65,7 +65,7 @@ func StartServer(host string, confServ *ConfigServer, configMsgChan chan *config time.Sleep(2 * time.Second) - grpcLog.Println("Start grpc config server ", ready) + grpcLog.Infoln("start grpc config server", ready) lis, err := net.Listen("tcp", host) if err != nil { grpcLog.Fatalf("failed to listen: %v", err) diff --git a/server.go b/server.go index 9d806baa..d824cad1 100644 --- a/server.go +++ b/server.go @@ -11,13 +11,13 @@ import ( "github.com/omec-project/webconsole/backend/logger" "github.com/omec-project/webconsole/backend/webui_service" - "github.com/sirupsen/logrus" "github.com/urfave/cli" + "go.uber.org/zap" ) var WEBUI = &webui_service.WEBUI{} -var appLog *logrus.Entry +var appLog *zap.SugaredLogger func init() { appLog = logger.AppLog @@ -31,7 +31,7 @@ func main() { app.Action = action app.Flags = WEBUI.GetCliCmd() if err := app.Run(os.Args); err != nil { - logger.AppLog.Warnf("Error args: %v", err) + logger.AppLog.Warnf("error args: %v", err) } }