Skip to content

Commit

Permalink
allow logger to report caller
Browse files Browse the repository at this point in the history
  • Loading branch information
d80tb7 committed Aug 23, 2023
1 parent b411037 commit 71ec882
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/common/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -80,6 +81,7 @@ func ConfigureCommandLineLogging() {
func ConfigureLogging() {
log.SetLevel(readEnvironmentLogLevel())
log.SetFormatter(readEnvironmentLogFormat())
log.SetReportCaller(readEnvironmentLogCallSite())
log.SetOutput(os.Stdout)
}

Expand All @@ -94,6 +96,17 @@ func readEnvironmentLogLevel() log.Level {
return log.InfoLevel
}

func readEnvironmentLogCallSite() bool {
level, ok := os.LookupEnv("LOG_REPORT_CALLER")
if ok {
logCallSite, err := strconv.ParseBool(level)
if err == nil {
return logCallSite
}
}
return false
}

func readEnvironmentLogFormat() log.Formatter {
formatStr, ok := os.LookupEnv("LOG_FORMAT")
if !ok {
Expand Down

0 comments on commit 71ec882

Please sign in to comment.