summaryrefslogtreecommitdiffstats
path: root/core/log.go
blob: 5960d6b8f75f3d391467b475611d44af67c30afd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package core

import (
	"os"

	logger "github.com/sirupsen/logrus"
)

var (
	debug       = os.Getenv("DEBUG_GOVPP") != ""
	debugMsgIDs = os.Getenv("DEBUG_GOVPP_MSGIDS") != ""

	log = logger.New() // global logger
)

// init initializes global logger, which logs debug level messages to stdout.
func init() {
	log.Out = os.Stdout
	if debug {
		log.Level = logger.DebugLevel
		log.Debugf("govpp/core: debug mode enabled")
	}
}

// SetLogger sets global logger to l.
func SetLogger(l *logger.Logger) {
	log = l
}

// SetLogLevel sets global logger level to lvl.
func SetLogLevel(lvl logger.Level) {
	log.Level = lvl
}