mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
2bb400910a
* set loggers library entry to repository url * remove comment
31 lines
697 B
Go
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)
|
|
}
|