Skip to content

Commit c74094b

Browse files
committed
feat(logging): Option to enable detailed source location
1 parent 923c03a commit c74094b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

logging/logging.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

1111
const (
12+
GatusLogSourceEnvVar = "GATUS_LOG_SOURCE"
1213
GatusConfigLogTypeEnvVar = "GATUS_LOG_TYPE"
1314
GatusLogLevelEnvVar = "GATUS_LOG_LEVEL"
1415
)
@@ -40,6 +41,16 @@ func levelFromString(level string) (slog.Level, error) {
4041
func Configure() {
4142
logHandlerOptions := &slog.HandlerOptions{Level: logLevel, AddSource: false}
4243

44+
logSourceAsString := os.Getenv(GatusLogSourceEnvVar)
45+
switch logSourceAsString {
46+
case "", "FALSE":
47+
break
48+
case "TRUE":
49+
logHandlerOptions.AddSource = true
50+
default:
51+
slog.Warn("Invalid log source value, defaulting to false", "provided", logSourceAsString)
52+
}
53+
4354
logTypeAsString := os.Getenv(GatusConfigLogTypeEnvVar)
4455
switch logTypeAsString {
4556
case "", "TEXT":

0 commit comments

Comments
 (0)