diff options
author | Matus Mrekaj <matus.mrekaj@pantheon.tech> | 2019-10-22 15:05:39 +0200 |
---|---|---|
committer | Matus Mrekaj <matus.mrekaj@pantheon.tech> | 2019-10-30 14:42:35 +0100 |
commit | 58601b470bbd4e5ef534fed83511aa5a7f1c2d1e (patch) | |
tree | 1c0c1176567d66e1b7be45c51f445dd5baa28dee /proxy/log.go | |
parent | cc80dbcaaaca8bf1b6042fead850d456cf589a4e (diff) |
fix data races in proxy server
Signed-off-by: Matus Mrekaj <matus.mrekaj@pantheon.tech>
Change-Id: I932d560548ee816e28683243a7318a2a7fbbb24a
Diffstat (limited to 'proxy/log.go')
-rw-r--r-- | proxy/log.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/proxy/log.go b/proxy/log.go new file mode 100644 index 0000000..2810528 --- /dev/null +++ b/proxy/log.go @@ -0,0 +1,30 @@ +package proxy + +import ( + "github.com/sirupsen/logrus" + "os" +) + +var ( + debug = os.Getenv("DEBUG_GOVPP_PROXY") != "" + + log = logrus.New() +) + +func init() { + log.Out = os.Stdout + if debug { + log.Level = logrus.DebugLevel + log.Debugf("govpp/proxy: debug mode enabled") + } +} + +// SetLogger sets global logger to l. +func SetLogger(l *logrus.Logger) { + log = l +} + +// SetLogLevel sets global logger level to lvl. +func SetLogLevel(lvl logrus.Level) { + log.Level = lvl +}
\ No newline at end of file |