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

Commit 285455d

Browse files
Fix issue where logserver reverts the logrus setting
1 parent 4278b06 commit 285455d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

debug.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ type DebugLogging struct {
2121
EnableDynamicLogLevel bool `usage:"Enable loglevel server to enable changing the log level at runtime"`
2222
}
2323

24+
func setIfUnset(envKey, value string) {
25+
if v := os.Getenv(envKey); v == "" {
26+
os.Setenv(envKey, value)
27+
}
28+
}
29+
2430
func (d DebugLogging) InitLogging() error {
2531
if d.Debug || d.DebugLevel > 0 {
2632
logging := flag.NewFlagSet("", flag.PanicOnError)
@@ -31,9 +37,11 @@ func (d DebugLogging) InitLogging() error {
3137
level = 6
3238
}
3339
if level > 7 {
40+
setIfUnset("ACORN_LOG_LEVEL", "trace")
3441
logrus.SetLevel(logrus.TraceLevel)
3542
logs.Debug = log.New(os.Stderr, "ggcr: ", log.LstdFlags)
3643
} else {
44+
setIfUnset("ACORN_LOG_LEVEL", "debug")
3745
logrus.SetLevel(logrus.DebugLevel)
3846
}
3947
if err := logging.Parse([]string{

0 commit comments

Comments
 (0)