Skip to content

Commit 86ff925

Browse files
committed
chore: support multiple keys in FromEnv
1 parent baae930 commit 86ff925

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

extra/reqlog/middleware.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ func WithVerbose(on bool) Option {
4040
// - BUNDEBUG=0 - disables the middleware.
4141
// - BUNDEBUG=1 - enables the middleware.
4242
// - BUNDEBUG=2 - enables the middleware and verbose mode.
43-
func FromEnv(key string) Option {
44-
if key == "" {
45-
key = "BUNDEBUG"
43+
func FromEnv(keys ...string) Option {
44+
if len(keys) == 0 {
45+
keys = []string{"BUNDEBUG"}
4646
}
4747
return func(m *middleware) {
48-
if env, ok := os.LookupEnv(key); ok {
49-
m.enabled = env != "" && env != "0"
50-
m.verbose = env == "2"
48+
for _, key := range keys {
49+
if env, ok := os.LookupEnv(key); ok {
50+
m.enabled = env != "" && env != "0"
51+
m.verbose = env == "2"
52+
break
53+
}
5154
}
5255
}
5356
}

0 commit comments

Comments
 (0)