Skip to content

Commit

Permalink
Merge branch 'master' into middleware_enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
shraddhafalane authored Aug 29, 2022
2 parents 2bdf2ba + 86ff925 commit 9421aed
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions extra/reqlog/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ func WithEnabledOtherParameter(on bool) Option {
// - BUNDEBUG=0 - disables the middleware.
// - BUNDEBUG=1 - enables the middleware.
// - BUNDEBUG=2 - enables the middleware and verbose mode.
// - BUNDEBUG=3 - enables the middleware and logs request heraders , path, ip and params.
// - BUNDEBUG=3 - enables the middleware and logs request headers , path, ip and params.

func FromEnv(key string) Option {
if key == "" {
key = "BUNDEBUG"
func FromEnv(keys ...string) Option {
if len(keys) == 0 {
keys = []string{"BUNDEBUG"}
}
return func(m *middleware) {
if env, ok := os.LookupEnv(key); ok {
m.enabled = env != "" && env != "0"
m.verbose = env == "2"
m.enabledOtherParameter = env == "3"
for _, key := range keys {
if env, ok := os.LookupEnv(key); ok {
m.enabled = env != "" && env != "0"
m.verbose = env == "2"
m.enabledOtherParameter = env == "3"
break
}
}
}
}
Expand Down

0 comments on commit 9421aed

Please sign in to comment.