1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-04 04:07:16 +02:00

assign library field in logger with respect of containing repository (#968)

* set loggers library entry to repository url

* remove comment
This commit is contained in:
Christopher Fenner 2019-11-11 15:31:02 +01:00 committed by GitHub
parent 5b598e82ce
commit 2bb400910a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -9,7 +9,11 @@ RUN go test ./... -cover
# execute build
# RUN go build -o piper
RUN export GIT_COMMIT=$(git rev-parse HEAD) && \
go build -ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT}" -o piper
export GIT_REPOSITORY=$(git config --get remote.origin.url) && \
go build \
-ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT}" \
-ldflags "-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GIT_REPOSITORY}" \
-o piper
# FROM gcr.io/distroless/base:latest
# COPY --from=build-env /build/piper /piper

View File

@ -4,12 +4,14 @@ 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", "sap/jenkins-library")
logger = logrus.WithField("library", LibraryRepository)
}
return logger
}