Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit bd05462

Browse files
ensure log contains endpoint (#47)
Signed-off-by: Ayman <[email protected]> Co-authored-by: Ayman <[email protected]>
1 parent b5f0c21 commit bd05462

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

cmd/git/git.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,12 +2632,16 @@ func main() {
26322632
ctx shared.Ctx
26332633
git DSGit
26342634
)
2635-
git.initStructuredLogger(&ctx)
2635+
git.initStructuredLogger()
26362636
err := git.Init(&ctx)
26372637
if err != nil {
26382638
git.log.WithFields(logrus.Fields{"operation": "main"}).Errorf("Error: %+v", err)
26392639
return
26402640
}
2641+
git.log = git.log.WithFields(
2642+
logrus.Fields{
2643+
"endpoint": git.URL,
2644+
})
26412645
timestamp := time.Now()
26422646
shared.SetSyncMode(true, false)
26432647
shared.SetLogLoggerError(false)
@@ -2654,22 +2658,15 @@ func main() {
26542658
}
26552659

26562660
// createStructuredLogger...
2657-
func (j *DSGit) initStructuredLogger(ctx *shared.Ctx) {
2658-
endpointURL := ""
2659-
if shared.FlagPassed(ctx, "url") && *j.FlagURL != "" {
2660-
endpointURL = *j.FlagURL
2661-
}
2662-
if ctx.EnvSet("URL") {
2663-
endpointURL = ctx.Env("URL")
2664-
}
2661+
func (j *DSGit) initStructuredLogger() {
26652662
logrus.SetFormatter(&logrus.JSONFormatter{})
26662663
log := logrus.WithFields(
26672664
logrus.Fields{
26682665
"environment": os.Getenv("STAGE"),
26692666
"commit": build.GitCommit,
26702667
"version": build.Version,
26712668
"service": build.AppName,
2672-
"endpoint": endpointURL,
2669+
"endpoint": j.URL,
26732670
})
26742671
j.log = log
26752672
}

0 commit comments

Comments
 (0)