Add SetLogger for setting global logger 71/28171/1
authorOndrej Fabry <ofabry@cisco.com>
Tue, 4 Aug 2020 13:24:02 +0000 (15:24 +0200)
committerOndrej Fabry <ofabry@cisco.com>
Tue, 4 Aug 2020 13:24:02 +0000 (15:24 +0200)
- list prerequisites in README
- avoid calling go list by hard-coding module path

Change-Id: Ib8af1934f55b7e112a8124a20f1f4d39ce651133
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Makefile
README.md
adapter/socketclient/socketclient.go

index 675deb9..5257617 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ SHELL := /usr/bin/env bash -o pipefail
 
 VERSION ?= $(shell git describe --always --tags --dirty)
 COMMIT ?= $(shell git rev-parse HEAD)
-BUILD_STAMP ?= $(shell git log -1 --format="%ct")
+BUILD_STAMP ?= $(shell git log -1 --format='%ct')
 BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
 
 BUILD_HOST ?= $(shell hostname)
@@ -10,7 +10,7 @@ BUILD_USER ?= $(shell id -un)
 
 GO ?= go
 
-GOVPP_PKG := $(shell go list)
+GOVPP_PKG := git.fd.io/govpp.git
 LDFLAGS = \
        -X ${GOVPP_PKG}/version.version=$(VERSION) \
        -X ${GOVPP_PKG}/version.commitHash=$(COMMIT) \
index 0f3b773..509e590 100644 (file)
--- a/README.md
+++ b/README.md
@@ -42,6 +42,10 @@ of linking the GoVPP core and all its dependencies into them.
     +--------------+
 ```
 
+## Prerequisites
+
+- [Go 1.13](https://golang.org/dl)
+
 ## Quick Start
 
 Make sure that $GOPATH, $GOROOT, and $PATH are set. If you cloned the
index 574ae06..637bd69 100644 (file)
@@ -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 = `