diff options
author | 2020-08-04 15:24:02 +0200 | |
---|---|---|
committer | 2020-08-04 15:24:02 +0200 | |
commit | 8049bd25baca6f5059ccd03c48a090607a65d8d0 (patch) | |
tree | b889dbae26129e60af8470f7308273b2a0f6ef31 /adapter/socketclient | |
parent | 58da9ac6e691a8c660eb8ca838a154e11da0db68 (diff) |
Add SetLogger for setting global logger
- list prerequisites in README
- avoid calling go list by hard-coding module path
Change-Id: Ib8af1934f55b7e112a8124a20f1f4d39ce651133
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'adapter/socketclient')
-rw-r--r-- | adapter/socketclient/socketclient.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/adapter/socketclient/socketclient.go b/adapter/socketclient/socketclient.go index 574ae06..637bd69 100644 --- a/adapter/socketclient/socketclient.go +++ b/adapter/socketclient/socketclient.go @@ -56,16 +56,21 @@ var ( debug = strings.Contains(os.Getenv("DEBUG_GOVPP"), "socketclient") debugMsgIds = strings.Contains(os.Getenv("DEBUG_GOVPP"), "msgtable") - logger = logrus.New() - log = logger.WithField("logger", "govpp/socketclient") + log logrus.FieldLogger ) -// init initializes global logger +// SetLogger sets global logger. +func SetLogger(logger logrus.FieldLogger) { + log = logger +} + func init() { + logger := logrus.New() if debug { logger.Level = logrus.DebugLevel - log.Debug("govpp: debug level enabled for socketclient") + logger.Debug("govpp: debug level enabled for socketclient") } + log = logger.WithField("logger", "govpp/socketclient") } const socketMissing = ` |