1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/log/log.go
Christopher Fenner 2bb400910a
assign library field in logger with respect of containing repository (#968)
* set loggers library entry to repository url

* remove comment
2019-11-11 15:31:02 +01:00

31 lines
697 B
Go

package log
import (
"github.com/sirupsen/logrus"
)
// LibraryRepository that is passed into with -ldflags
var LibraryRepository string
var logger *logrus.Entry
// Entry returns the logger entry or creates one if none is present.
func Entry() *logrus.Entry {
if logger == nil {
logger = logrus.WithField("library", LibraryRepository)
}
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)
}