2019-11-04 14:43:33 +01:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2019-11-11 15:31:02 +01:00
|
|
|
// LibraryRepository that is passed into with -ldflags
|
|
|
|
var LibraryRepository string
|
2019-11-04 14:43:33 +01:00
|
|
|
var logger *logrus.Entry
|
|
|
|
|
|
|
|
// Entry returns the logger entry or creates one if none is present.
|
|
|
|
func Entry() *logrus.Entry {
|
|
|
|
if logger == nil {
|
2019-11-11 15:31:02 +01:00
|
|
|
logger = logrus.WithField("library", LibraryRepository)
|
2019-11-04 14:43:33 +01:00
|
|
|
}
|
|
|
|
return logger
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetVerbose sets the log level with respect to verbose flag.
|
|
|
|
func SetVerbose(verbose bool) {
|
|
|
|
if verbose {
|
|
|
|
//Logger().Debugf("logging set to level: %s", level)
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetStepName sets the stepName field.
|
|
|
|
func SetStepName(stepName string) {
|
|
|
|
logger = Entry().WithField("stepName", stepName)
|
|
|
|
}
|